O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exact Verification by Value

Before we proceed further, let’s apply a technique from Chapter 6 to our current topic of dealing with strings. One of the basic techniques was sharing constants. In our example, we showed how to use a constant for a default value in a way that simultaneously clarified the intent of the code and made it more testable. At the risk of stating the obvious, that same technique applies well to string verification—and not just verification of default values.

Let’s look at the example of a web controller that, for reasons of compatibility, needs to translate URL parameters from an older version to a newer one. For brevity, let’s assume that we only need to translate a single parameter and that we have a method in our class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required