Test Smell: Missing Abstractions
Learn the importance of abstraction and how to add it where needed in the tests.
We'll cover the following
A well-structured test distills the interaction with the system into three portions:
- Arranging the data.
- Acting on the system.
- 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
A good test is an abstraction of how clients interact with the system.
Our muddled test contains five lines that assert against the list of matches
returned by search.getMatches()
. We must read these five lines individually to understand what’s going on:
Get hands-on with 1400+ tech skills courses.