Assert list size
When testing collection sizes with JUnit Jupiter, it's easy to make mistakes with argument order or write verbose assertions.
Type-specific assertions
AssertJ provides rich, expressive assertions tailored to specific types. These specialized assertions make your tests more readable and provide better failure messages compared to generic boolean checks.
Chained assertions
There are many different ways to write AssertJ assertions.
Multiple assertions
When checking for multiple elements, chaining assertions is cleaner than multiple separate assertTrue() calls.
Precise assertions
While contains() verifies that specific elements are present in a collection, it doesn't ensure that only those elements exist.
Migrate to AssertJ
You can easily convert existing assertions to use AssertJ using OpenRewrite's AssertJ recipe.
Encourage usage
After you've migrated to AssertJ once, you'll want to ensure that all new tests also use AssertJ.