You may have some trouble with any
or argThat
for primitive-type arguments to when
and verify
. Those Object-centric methods do their work with side-effects correctly, but they tend to return null
for a dummy return value, which doesn’t work for Java unwrapping primitives via auto-boxing.
Luckily, the org.mockito.ArgumentMatchers
class has a full complement of primitive-centric methods (of which I’ve listed the int
methods here):
static int anyInt()
static int eq(int value)
static int intThat(org.hamcrest.ArgumentMatcher<java.lang.Integer> matcher)
See all of them at the documentation for the ArgumentMatchers class.