assertj-examples icon indicating copy to clipboard operation
assertj-examples copied to clipboard

Apply a few assertion best practices

Open timtebeek opened this issue 6 months ago • 1 comments

  • There were some drop in replacements not yet applied, like isCloseTo.
  • A bit of weird formatting in NumberAssertionsExamples where the next assertThat was on the end of the previous line.
  • A missing hasToString instead of ....toString()).isEqualTo(...

timtebeek avatar Oct 04 '25 23:10 timtebeek

I had intentionally left out a few optimization that are redundant, such as the check here on isPresent() in a method chain where the subsequent assertion imply the entry is present: https://github.com/assertj/assertj-examples/blob/b9c1a9095cb195c161d05b4de6ce8bfa5c0e53e0/assertions-examples/src/test/java/org/assertj/examples/OptionalAssertionsExamples.java#L40-L45

While that could be an improvement in actual use, this repository aims to show the breadth of assertions available, which then makes sense to leave that isPresent() and others in, perhaps. If you feel we can drop those for clarity then let me know.

timtebeek avatar Oct 05 '25 09:10 timtebeek