Test Abstraction
Uncle Bob defines abstraction as “amplification of the essential and elimination of the irrelevant.” Abstraction is as important in your tests as it is in object-oriented design. Since you want to be able to read your tests as documentation, they must cut to the chase, declaring their intent as clearly and simply as possible.
From a simplistic stance, you can increase abstraction in your tests by making them more cohesive (One Assert per Test), focusing on better naming (for the test itself as well as the code within), and abstracting away the rest of the cruft (using perhaps fixture helper functions or SetUp).
We’ll work through identifying nine different test smells and cleaning up test code accordingly.
Bloated Construction ...
Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.