Issue Details (XML | Word | Printable)

Key: FEST-242
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Alex Ruiz
Reporter: Szczepan Faber
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
FEST

nicer debugging output with jUnit's ComparisonFailure

Created: 12/Oct/09 03:04 PM   Updated: 19/Oct/09 12:38 AM   Resolved: 19/Oct/09 12:38 AM
Return to search
Component/s: Assert
Affects Version/s: FEST-Assert 1.1
Fix Version/s: FEST-Assert 1.2

Time Tracking:
Not Specified


 Description  « Hide

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:

  1. assertThat(foo).isEqualTo(foo2);
  2. if the assertion fails
    1. if the foo.toString() is not equal to foo2.toString() then throw new ComparisonFailure(foo.toString(), foo2.toString())
    2. if the foo.toString() is equal to foo2.toString() then DON'T throw ComparisonFailure because it is confusing
  3. 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



Alex Ruiz added a comment - 19/Oct/09 12:38 AM

I fixed this issue some time ago, but I forgot to create an issue for it.