Adding messages to JUnit, FEST and AssertJ assertions is an investment in your future productivity. Spend a few seconds writing them now, and you'll save a lot of time on the other end when either the tests fail and you need to quickly diagnose the problem, or when you need to maintain the tests and the assertion messages work as a sort of documentation.
assertEquals("There should have been 4 Fruits in the list", 4, list.size());
try {
fail("And exception is expected here");
} catch (Exception e) {
assertThat(list.get(0)).as("check first element").overridingErrorMessage("The first element should be a pear, not a %s", list.get(0)).isEqualTo("pear");
\[~ann.campbell.2] I think we should we also cover FestAssertions in this rule (which we use a lot internally, like more (instead of?) Junit assertions).
=== on 9 Apr 2015, 13:03:39 Ann Campbell wrote:
how's that?
=== on 9 Apr 2015, 13:14:05 Nicolas Peru wrote:
Looks good.
=== on 26 May 2020, 15:44:14 Johann Beleites wrote:
This rule appears extremely noisy for AssertJ (and potentially Fest?) - consider twice before putting it into the default profile.