-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add method names as constants #192
Comments
Elsewhere I saw a beautiful solution: mock has a special field, say "EXPECT" where all method control behavior is defined: mock.EXPECT.Add(mock.Anything).Return() |
@tutukin In this case, the restrictions are related to the library that is used for mocks For example, in another library implemented as: phoneBook := NewMockPhoneBook()
// Stubbing:
pegomock.When(phoneBook.GetPhoneNumber(AnyString())).Then(func(params []Param) ReturnValues {
return []ReturnValue{fmt.Sprintf("1-800-CALL-%v", strings.ToUpper(params[0]))}
},
// or
pegomock.When(phoneBook.GetPhoneNumber("Tom")).ThenReturn("345-123-789")
// Prints "1-800-CALL-DAN":
fmt.Println(phoneBook.GetPhoneNumber("Dan"))
phoneBook.VerifyWasCalledOnce().GetPhoneNumber("Tom") |
I like this idea! I'll tag this for consideration... |
Implemented a very similar solution to this in #396, although I had to make the EXPECT a method to get the underlying mock. |
Closed as we now have |
Example:
The text was updated successfully, but these errors were encountered: