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

Data Injection

The simplest form of override encapsulation allows you to inject simple data into the software under test. No matter how much you model actors in your system as objects, attributes are still the fundamental building blocks. Let’s start by using encapsulation and overriding with basic data types as shown in Listing 8-1.

Listing 8-1: Code under test for basic data type injection

public class TemperatureWatcher {  public static final double REALLY_COLD_F = 0.0;  public static final double REALLY_HOT_F = 100.0;  public static final String REALLY_COLD_RESPONSE =      "Really cold!";  public static final String REALLY_HOT_RESPONSE =      "Really hot!";  public static final String NORMAL_RESPONSE = "Okay"; ...

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