A Practical Guide to Testing Object-Oriented Software

  • Need to know what must be retested in code that is inherited? See Hierarchical, Incremental Testing.

  • Want to encapsulate the test cases for a specific class using PACT? See Organizing Testing Software.

  • Want to know what testing is possible if the class is abstract? See Testing Abstract Classes.

Inheritance is a powerful mechanism for interface and code reuse. In this chapter we describe approaches for the execution-based testing of classes in an inheritance hierarchy. We show how to test a subclass given that its superclass has been tested using the techniques in Chapter 5 and Chapter 6. We consider many aspects of subclass testing, including adequate testing of subclasses, reuse of test cases for a class in testing subclasses of that class, and implementation of test drivers for subclasses. We also cover testing abstract classes. We provide examples of the techniques in both C++ and Java.

We begin the chapter with a brief review of inheritance and a discussion of assumptions we make about how inheritance should be used. Then we analyze the inheritance relationship from a testing perspective to identify what needs to be tested in a subclass. We describe parallel architecture for class testing (PACT), which is a way to organize Tester classes in an inheritance hierarchy.

Категории