I am working on some tests for a project here at my company. I used Mockito.verify(...)
in combination with some ArgumentCaptor
quite a bit but know I am a bit puzzeled, because in my case the following test code does not work out as expected:
@Mock BuildHandler buildHandler;
...
ArgumentCaptor<Build> savedBuildCaptor = ArgumentCaptor.forClass(Build.class);
verify(buildHandler, times(1)).save(savedBuildCaptor.capture());
...
I expected the savedBuildCaptor
to catch me any Build
object that is passed to the buildHandler.save(Build b)
method. In fact during the execution I end up with this test failure from Mockito:
Argument(s) are different! Wanted: buildHandler.save(null);
Actual invocation has different arguments: buildHandler.save(1234);
Can anyone point me to where I (might have) screwed up?
If additional code/info is required I'll post it.