Q:

Dynamicaly changing behavior of mocks in Mockito

Hello I would like to know, if there is any way to dynamicaly modify behaviour of mocks in Mockito.
For example I have a method count() and I would like Mockito to return a value higher by one every time I call it on mock.
Thank you.

A:

Yes... Create an Answer and stub it out on your mock using doAnswer().

