- Comparing with failure tracing is not an easy task when your object is a bit more complex.
- Comparing with the debugger is useful if you have not redefined toString (). This is still very tiring, as you have to check with your own eyes all the objects on both sides.
The Junit Eclipse plugin offers an option on failure: "Compare actual with expected testing." The view is quite close to the classic content comparison tools: 
The problem is that it is available only when you write assertEquals() with String objects (in the screenshot we see that the option in the corner is not offered without the String class): 
You can use toString() for your object in a statement, but this is not a good solution:
- firstly, you correlate
toString() with equals(Object) ... a modification of one should entail a change in the other. - secondly, semantics are no longer respected.
toString() should return a useful method for debugging the state of a single object, and not for identifying an object in the semantics of Java ( equals(Object) ).
In my opinion, I think the JUnit Eclipse plugin is missing a function.
When the comparison fails, even if we are comparing String objects, it should offer a comparison of two objects that rely on their toString() method.
It can offer a minimal visual way of comparing two uneven objects.
Of course, since equals(Object) does not necessarily correlate with toString() , the highlighted differences should be studied by our eyes, but this will already be a very good foundation, and in any case it is much better than no comparison tool.
source share