Open larmic opened 5 years ago
// this verification is already defined by whenever(...) verify(mock).ping()
verify(...)
checks that mock.ping()
is invoked. Whenever(...)
verifies nothing, but just defines what should happen if mock.ping()
is invoked. And this depends on the implementation of pingService.sendPing()
.
Yes you are right. But a verifyNoMoreInteractionsAndVerifyWhenever
could help.
My tests often look like the one described above. And (for me) it feels like duplicating code.
Would Mockito's Strictness API help here?
It will be reduce code if
verifyNoMoreInteractions
will not checkwhenever
-calls or this could be configurable by an optional parameter.