Closed imosquera closed 10 years ago
This would have to be supported by gomock, as that is where all the heavy lifting of the expectation management is done. The code generated by withmock is just a wrapper for Controller.Call() and Controller.RecordCall().
gomock already has .AnyTimes(), so you can do mockObj.EXPECT().MyMethod(myParam1).Return(nil).AnyTimes(). The gomock controller actually stores the min and max number of calls, so something like .MinCalls(0) should be possible ... no changes to withmock would be needed.
Thanks Julian. This will work.
Currently if i mock a method using the standard
it will throw an error if
MyMethod
isn't called. But what if I would like mock a method but not confirm that it's called?I'm proposing we create a
WHEN()
method.This just mocks the object but if it's not called during the test it won't throw an error.
Is this possible in the
withmock
project or will this have to be rewritten in the go-mock project?