Chapter 7. Improving Readability with Custom Assertions
In this chapter, you'll learn to write concise verifications that reveal the expected outcome of a test clearly. You'll be taught how domain-specific assertions help to improve readability and reduce boilerplate at the same time. To achieve this, you'll be given an overview of the respective capabilities and limitations of the various JUnit test verification techniques. In detail, you'll be introduced to the built-in mechanism, Hamcrest matchers, and AssertJ asserts. In this chapter, we will discuss the following topics:
- Working with the JUnit built-in assert approach
- Creating flexible expressions of intent with Hamcrest
- Writing fluently readable assertions with AssertJ