Exact Verification with Formatted Results

Going back to our example from Listing 7-1 with the describeAddition() method, even our Perl example left us with completeness, ordering, and localization issues. While these are less severe issues than the ones we started with, the increasing global reach and rapid pace of development make them suboptimal.

Let’s recap what we have considered. Containment is weak and prone to false successes. Regular expressions provide a little more robustness but still have completeness and ordering issues. We could use constants instead of our literal strings, but this would not solve the outstanding problems if we only applied it to the joining fragments of the result.

But what if we consider a constant that can ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.