FEST currently uses ComparisonFailure when doing isEqualTo with Strings. ComparisonFailure has some extra benefits in modern IDEs, e.g. Eclipse offers extra pop-up info with detailed comparison highlighting the differences.
I propose to use this exception for isEqualTo on other types as well. It could work like this:
- if the assertion fails
- if the foo.toString() is not equal to foo2.toString() then throw new ComparisonFailure(foo.toString(), foo2.toString())
- if the foo.toString() is equal to foo2.toString() then DON'T throw ComparisonFailure because it is confusing
- assertion doesn't fail. Good for you.
This is a proposal and if you guys think it is useful the please stick it into November release. I think it is useful because on the occasion I remember I temporarily refactored assertions into assertEquals(expected.toString(), actual.toString()) just to have nicer message