Closed jpopadak closed 5 years ago
Hey @jpopadak,
So this one is easy :-). Check out the Stubbing section. Below the example it says:
ThenReturn
supports chaining, i.e.ThenReturn(...).ThenReturn(...)
etc. The mock will return the values in the same order the chaining was done. The values from the lastThenReturn
will be returned indefinitely when the number of call exceeds theThenReturn
s.
Hope this helps! If not, let me know how I can improve the description. Thanks, Peter
Whoops... I had two other engineers look at this and we didnt see that. 🙄 Sorry about that.
Right now,
ThenReturn
validates the values sent into it match the types and number of response values.However, there is no quick way to setup multiple calls to return different values.
For example, my logic calls
RequestToken()
this function 3 times, and on the 3rd time I want a different result.I would expect functionality like this to occur just like Mockito style responses:
In this scenario, there are 6 values sent to
ThenReturn
. It would be nice if it could see its a multiple of the values I wanted to send in, and then validate the types (in this case a pair ofResponse
andError
) for each "set of 2" values.If it doesnt make sense from a user API/DSL side, we could do something like
ThenReturnMultiple
.