0

Mockito – thenReturn or thenAnswer?

Mockito – thenReturn or thenAnswer?

This post demonstrates that thenReturn is designed to return the same value every time the stubbed method is invoked and that thenAnswer provides a way to vary the returned values after each method invocation. Generally, we use thenReturn to return “hardcoded” values; we use thenAnswer to use some complex logic to generate and return a value. Continue Reading

0

Capture Argument Passed to a mock’s method in Mockito

Capture Argument Sometimes verifying whether or not a method was invoked is not enough.  Some scenarios need verifying values passed to mock object’s methods. To do this, we use:

Here is sample usage:

Download the Codes https://github.com/Turreta/VoidMethodsAndMockito I… Continue Reading