![]()  | Test of Object-oriented Programs | 
| A complete PDF version of the text book is now available. The PDF version is an almost complete subset of the HTML version (where only a few, long program listings have been removed). See here. | 
54.1.  Introduction to Program Testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 Testing according to Glen Myers book "The art of Software Testing"  | 
  | 
Program testing is very resource and time consuming It is not unusual to spend 40% of the total project efforts on testing  | 
54.2.  Overview of Program Testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
  | 
54.3.  Testability
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 Testability refers to the software qualities that affect our ability to reveal errors  | 
  | 
Design for Testability  | 
54.4.  Test Utopia
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 In the ideal world, all possible paths through a programs should be tested  | 
  | 
  | 
 In the real world, we need to select a subset of the paths in a total test which most likely
                          will reveal possible program errors  | 
54.5.  From Program Test to Program Proof
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 A mathematical program proof is an alternative to program testing  | 
  | 
Manually performed program proofs are likely to have more errors in the proof than in the program Therefore only automatic program proofs will improve our confidence  | 
54.6.  White box testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
White box testing uses the control structures of a program unit to derive test cases The aim of white box testing is to guarantee that all commands and expressions in a given program are executed at least once  | 
  | 
54.7.  Basis Path Testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 Basis path testing is a white box testing technique that helps select a minimal
                  set of paths through a program unit that covers all statements and conditions  | 
  | 
  | 
54.8.  Cyclomatic Complexity - flow chart
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  |    public static void P(){
    // Entry 
    while(A){
      X;
      if (B){
        if(C)
          Y;
        else 
          Z;
        // p
      } else{
         V; W;
      }
      // q
    }
    // Exit: r
  } | |||
  | 
 | Figure 54.1 The flow chart for the program unit P | 
54.9.  Cyclomatic Complexity - flow graph
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 A slight abstraction of the flow chart leads to a so-called flow graph  | 
 | Figure 54.2 The accompanying flow chart for the program unit P | 
| A, r | A, X, B, C, Y, p, q, A, r | 
| A, X, B, C, Z, p, q, A, r | A, X, B, V, W, q, A, r | 
| Table 54.1 | 
54.10.  Cyclomatic Complexity - Metric and Test Cases
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
 Calculation of the test metric and finding test cases  | 
  | 
| Exercise 14.1. Cyclomatic complexity of GCD Find the cyclomatic complexity of Euclid's, gcd, function in this C program. If possible, find test cases that allow you to test each independent path of the gcd function. Independent paths are defined here in course material. How many test cases do you actually need to cover all source lines of the gcd function? Solution | 
54.11.  Black box testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
Black box testing uses the interface of a program unit to derive test cases The aim of black box testing is to demonstrate that the program unit produces correct output on suitable input - relative to the functional requirements  | 
  | 
54.12.  Input to a Black Box Test
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
It is not realistic - from a combinatoric point of view - to test a program unit on all possible inputs Therefore, the choice of input values to black box testing is an important concern  | 
  | 
  | 
54.13.  Example of Equivalence Partitioning (1)
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
1 2 3 4  |    // Exchange element i and j in table
  public void SwapElements<T>(T[] table, int i, int j){
    ...
  } | |||
  | 
  | 
 Use of a stronger precondition limits the number of test cases  | 
54.14.  Example of Equivalence Partitioning (2)
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
1 2 3 4 5 6 7  |    // Find the largest element in table in between the indexes from and to.
  // Return the index of this element.
  // Precondition: 0 <= from <= to <= table.Length-1
  public int FindMaxIndex<T>(T[] table, int from, int to)
    where T: IComparable<T> {
       ...
  } | |||
  | 
  | 
 A well-chosen precondition limits the number of test cases substantially  | 
54.15.  Regression testing
Contents   Up Previous Next   Slide Annotated slide Aggregated slides    Subject index Program index Exercise index 
The purpose of regression test is to find regression errors A regression error is an error in a previously correct program, which recently has been modified A regression error is an error which not used to be there  | 
  | 
  | 
54.16.  References
| [-] | Software Engineering - A Practitioner's Approach: Roger S. Pressman, McGraw-Hill, 1992 |