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 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.