Since our use of AssertJ is relatively new, we should document in the wiki which parts of the AssertJ APIs are preferable for use in tests.
Doing so will avoid debates about what is the right way to assert something when AssertJ offers more than one way to achieve the same thing — for example, assertThat(collection).size().isEqualTo(n)
vs. assertThat(collection).hasSize(n)
.
Comment From: rstoyanchev
Team Decision: we should review the existing usages and look for patterns, and specific changes to propose to make tests more consistent, and/or come up with recommendations if any.
Comment From: snicoll
Due to the lack of follow-up on this issue, our use of assertJ has grown organically and we're mostly relying on AssertJ best practices anyway, e.g. use hasSize()
for collections rather than size()).isEqualTo
. Also old tests have been migrated but we haven't really taking the time to review the assertions (I've been doing this lately) so whatever document we'd write would be at odds with that.
I don't think this issue is actionable. Inconsistencies that we discover should be brought up and, ideally, a Checkstyle rule should be put in place if we want to enforce a pattern.