jspoon icon indicating copy to clipboard operation
jspoon copied to clipboard

Incorrect unit test ComparisonFailure messages

Open cr3ativ3 opened this issue 8 years ago • 2 comments

Most of jspoon's unit tests (the ones not written by me) has assertEquals(arg1, arg2) with arguments switched places. They have first actual then expected, when it should be first expected then actual. That results in misleading junit's error messages upon test failure:

String actual = "actual";
assertEquals(actual, "expected");

org.junit.ComparisonFailure: expected:<[actual]> but was:<[expected]>

cr3ativ3 avatar Mar 22 '18 18:03 cr3ativ3

Good catch. We migth consider switching e.g. to assertJ. It uses assertThat("actual").isEqualTo("expected") so it is harder to make such mistakes.

koral-- avatar Mar 22 '18 23:03 koral--

I don't know if its any harder to write assertThat("expected").isEqualTo("actual"). Though assertj's builder style assertions does make it easier if do multiple chained evaluations on the same instance, but haven't seen that many use-cases in jspoon.

cr3ativ3 avatar Mar 25 '18 17:03 cr3ativ3