Search⌘ K

Test Smell: Missing Abstractions

Explore how to refactor your JUnit tests by adding meaningful abstractions such as custom matchers and clearer assertions. Understand how simplifying test details helps reduce mental clutter and improves readability and maintainability.

We'll cover the following...

A well-structured test distills the interaction with the system into three portions:

  1. Arranging the data.
  2. Acting on the system.
  3. Asserting on the results.

Although the test requires detailed code to accomplish each of these steps, we can improve understanding by organizing those details into abstractionsCode elements that maximize the essential concepts and hide the unnecessary details..

A good test is an abstraction of how clients interact with the system.

Our muddled test contains five lines that assert against the ...