Tests As Documentation
Learn how to document tests for better understanding.
As the final task, let’s revisit the set of test names in ProfileTest
:
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 with care, the more the tests can document the behaviors deliberately designed into Profile
.
Better test names
When seeking to better understand a test-driven class, start by reading its test names. The comprehensive set of test names should provide a holistic summary of the intended capabilities of the class. The more the test ...