Mockito.verify method contains boolean and argument

I do not know how to use Mockito.verifyin this case. How can I pass false to Mockito.verify? I try 2 different ways, but it does not work.

public Sample someMethod(Sample s, boolean a){....}
@Test
public void test() {
...
verify(mock).someMethod(sampleCaptor.capture(), false));
verify(mock).someMethod(sampleCaptor.capture(), org.mockito.Matchers.eq(false)));
...
}
+4
source share
1 answer

Everything is right with you:

verify(mock).someMethod(sampleCaptor.capture(), Matchers.eq(false));

When using Matchers (including ArgumentCaptor.capture) you need to use Matcher for each value, because Matches work through side effects .

, . Mockito.validateMockitoUsage() verify, , Mockito . ( , " ", , .)

+7

Source: https://habr.com/ru/post/1613629/


All Articles