I want to skip checking one of the parameters in a verify call. So for:
def allowMockitoVerify=Mockito.verify(msg,atLeastOnce()).handle(1st param,,3rd param)
I want to skip checking for the second parameter. How can I do that?
Mockito Verify methods are used to check that certain behavior happened. We can use Mockito verify methods at the end of the testing method code to make sure that specified methods are called.
Mockito verifies argument values in natural java style: by using an equals() method.
Mockito verifyZeroInteractions() method It verifies that no interaction has occurred on the given mocks. It also detects the invocations that have occurred before the test method, for example, in setup(), @Before method or the constructor.
Unfortunately Mockito wont allow you to mix and match raw values and matchers (e.g. String and Matchers.any())
However you can use the eq() Matcher to match against a specific value, for example
Mockito.verify(msg, atLeastOnce())
.handle(eq("someValue"), any(Thing.class), eq("anotherValue"));
Thanks to this post for a good example of this Mockito: InvalidUseOfMatchersException
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