Mockito.verify not behaving properly when using a capture [closed]

1 week ago 11
ARTICLE AD BOX

I recently upgraded to jdk21 and a test started failing on this line:

verify(this.myService, times(2)).myMethod(myCaptor.capture());

The issue seems to be the use of a capture. If I remove it (replace with 'any()' for example), the test passes. If I remove the 'times(2)', the test also passes (though there's only a single value in the capture list).

Progman's user avatar

Progman

20.1k7 gold badges60 silver badges89 bronze badges

ticktock's user avatar

2

Read Entire Article