June 2025
Intermediate to advanced
1129 pages
53h
English
The problem with the simple tests is that they always end up being simple truth tests. Let’s construct an example. Suppose we want to check whether a collection contains two desired elements. We could write the following test:
assertTrue( collection.contains(elem1) && collection.contains(elem2) );
If the test fails, some questions will remain unanswered:
Was the first or the second element not in the collection? So, which was present, and which was missing?
What’s in the collection in total?
Of course, these questions can be answered by your own implementation, but various JUnit supplements can help, including AssertJ (https://assertj.github.io/doc), Truth (https://truth.dev/), or Hamcrest ...
Read now
Unlock full access