November 2024
Intermediate to advanced
300 pages
7h 12m
English
The big question every test must clearly answer: why does it expect the result it does? Developers must be able to correlate any assertions with the arrange step. Unclear correlation forces developers to wade through code for meaning.
The returnsMatchesWithSurroundingContext test searches for practical joke in a long string, expecting one match. A patient reader could determine where practical joke appears and then figure out that ten characters before it and ten characters after it represent the string:
| | "or a vast practical joke, though t" |
But making developers dig for understanding is rude. Make things explicit by choosing better test data. Change the input stream to contain a small amount of text. Then, change ...
Read now
Unlock full access