AssertJ

A Java library of fluent assertions, starting with assertThat, that read like sentences and explain failures in detail.

In more detail

AssertJ assertions describe collections, strings and exceptions precisely, for example containsExactly checks both the elements and their order. When one fails, the message shows the expected and actual values and the difference. Use exact order only when the contract promises it.

Examples

assertThat(names).containsExactly("Ada", "Lin");
In this course: Java needs it because the language has no pytest-style assertion rewriting. It pairs with JUnit, which runs the tests while AssertJ describes the checks.

Related terms

Taught in

References