Skip to content
Advertisement

Why is the or-Matcher not working in my Mockito verify?

I would like to verify that either of the following two method calls get executed once:

JavaScript

I have tried the following:

JavaScript

But running the test method resulted in the following error:

JavaScript

When I just test for a single method call as follows..

JavaScript

..it runs fine and my test is always successful when logWarn() gets called with argument "My 1st Warning Message".

Advertisement

Answer

AdditionalMatchers are used to implement common logical operations (‘not’, ‘and’, ‘or’) on ArgumentMatchers

So following code:

JavaScript

Should work as expected.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement