Mokito complains about wrong arguments

We are trying to test the behavior of an action with Mockito. The verification code looks like this:

final Type1 mock = mock(Type1.class); new SomeAction<Type1>(mock).actionPerformed(null); verify(mock).someMethod(); 

The actionPerformed method only contains a call to someMethod for the object provided in the Type1 constructor. However, Mockito complains that the expected method call did not happen; instead, another method call occurred. But the string representation of the two calls printed by Mockito is exactly the same!

Any explanation what is going on?

Update: ErrorMessage from Mockito

 Argument(s) are different! Wanted: type1.someMethod(); -> at xxx Actual invocation has different arguments: type1.someMethod(); -> at xxx 
+6
java testing mockito
source share
1 answer

This is a bit stretched, but check out the implementation of toString. I came across some annoying unit test scripts where the expected and observed were the same in terms of unit test, when in fact they were different. In the end, it was a variation of toString that made me believe that there were similarities when it really wasn't.

+3
source share

All Articles