The following test fails with org.mockito.exceptions.verification.TooManyActualInvocations for no apparent reason.
Mockito logs point out 2 invocations: first is the one I expect and the second one is in setUp() method's when() call.
I do not recall Mockito counting in when() calls, it makes zero sense.
Does this have to do with Answers.RETURNS_DEEP_STUBS or am I missing something else?
@RunWith(MockitoJUnitRunner.class)
public class MyTest {
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private FooService mockedObject;
void setUp() {
when(mockedObject.putParameter(any()).firstChainCall().secondChainCall()).thenReturn(HttpStatus.SC_OK);
}
@Test
public void foo() throws Exception {
runStuff();
verify(mockedObject).putParameter(any());
}
}
It's counting your setup as invocations since deeps stubs is not supported in the verification API, and complains on the second call
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With