How can you verify a mocked object is not invoked at all? I am trying to test the empty implementation of an interface method using Mockito.
I use org.mockito.Mockito.verifyNoMoreInteractions.
In fact, personally, I always include this section in all my Mockito tests:
@After
public void after() {
verifyNoMoreInteractions(<your mock1>, <your mock2>...);
}
So it acts as a handy catch-all to ensure that the test has no left-over, unexpected invocations that I haven't specifically verified.
I find that more useful than cluttering the tests with specific verifyZeroInteractions.
See Mockito API Article 7. Making sure interaction(s) never happened on mock
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