Tests As Documentation
As the final task, let’s revisit the set of test names in ProfileTest:
| matchesWhenProfileContainsMatchingAnswer |
| doesNotMatchWhenNoMatchingAnswer |
| matchesWhenContainsMultipleAnswers |
| doesNotMatchWhenNoneOfMultipleCriteriaMatch |
| matchesWhenAnyOfMultipleCriteriaMatch |
| doesNotMatchWhenAnyMustMeetCriteriaNotMet |
| matchesWhenCriterionIsDontCare |
| scoreIsZeroWhenThereAreNoMatches |
We want readers to be able to quickly answer questions about the behavior of the Profile class. The more we craft the tests for it with care, the more the tests can document the behaviors deliberately designed into Profile.
When seeking to better understand a test-driven class, start by reading its test names. The comprehensive set of test names should ...
Get Pragmatic Unit Testing in Java 8 with JUnit 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.