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

Declarative Scope Changing

Some of the more dynamic languages—I have used this with Perl in particular—allow you to declaratively change the scope of a block of code, much like reflection-base coercion. Although this features carries great potential for evil if you use it to pry open other people’s encapsulation, we use it only for good. It leverages the general principle of using the rules of packages to give tests access to the code they are testing, doing so in a more targeted and purposeful way.

Let’s look at an example using the Class::Std module for Perl object-oriented development (Listing 9-13). Class::Std lets you ascribe methods with traits that represent their visibility, much like the protected and private keywords in Java and C++. ...

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