Objectives

In this section a framework for testing object-oriented programs is sketched. First, the various levels of testing are briefly characterized and the possible influence of errors discussed. We transfer the insights of the previous section to an object-oriented setting, illustrated with a few simple examples. These examples are then used to show how contracts may be employed to monitor the runtime consistency of a system. Finally, some methods of static testing are treated, such as code inspection and walkthroughs, to complete the picture of possible methods for testing object-oriented programs.

Points to emphasize

Hints

The notions of state and state transitions play an essential role in object testing. Interaction sequences resulting in identity transitions may be employed to abstract from the combinatorial complexity of state changes. When designing a class, a number of tests may be included as an additional member function. Such a test function should include a representative collection of interaction sequences.

Questions

  1. Between what levels of testing can you distinguish? Discuss the influence of errors for each of these levels.
  2. Discuss the problems involved in testing the behavior of an object. What would be your approach?
  3. Discuss how contracts may be employed to test object behavior.
  4. What ways of static testing can you think of? Do you consider them relevant? Explain.

Comments

Contracts provide a means for strong testing, including both formal verification and runtime consistency checking. In practice, however, the design of appropriate contracts is not an easy task.