Monday, July 11, 2011

The Art of Software Testing by Glenford Myers : Chapter 4

The author discuss about how to design test cases in this chapter. The problem is to determine what subset of the possible test cases has the highest probability of detecting the most errors. The author then tries to develop a strategy which uses black-box-oriented test-case-design methodologies combined with testing the logic of the program using white-box testing.

The author then discusses following methods of test-case design:
  1. Logic-Coverage testing: The author discusses about designing a testing strategy such that every code path is executed exactly once. The author provides an example program and shows that it is a very weak criterion. The stronger criterion for logic coverage is called decision coverage or branch coverage. The criterion states that every decision has true or false outcome at least once. Decision coverage generally satisfies the statement coverage except when
    • The program has multiple entry points
    • The program has no decisions
    • The author then discusses a stronger method called condition coverage where each condition in a decision takes on all possible outcomes at least once.
  2. Equivalence partitioning: Since exhaustive-input test of a program is impossible, selecting the subset of test cases with the highest probability of finding the most errors is required. Test case design by equivalence classes proceed in two steps:
    • Identifying the equivalence classes: Each input condition is partitioned into two or more groups such as valid equivalence class, invalid equivalence class and external condition. The author then provides some guidelines for finding equivalence classes:
      • If an input condition specifies a range of values, identify one valid equivalence class and two invalid equivalence classes.
      • If an input condition specifies the number of values, identify one valid equivalence class and two invalid equivalence classes.
      • If an input condition specifies a set of input values, identify one valid equivalence class for each value and one invalid equivalence class.
      • If a condition specifies a "must be" situation, identify one valid equivalence class and one invalid equivalence class.
    • Defining the test cases: This follows following process:
      • Assign a unique number to each equivalence class.
      • Until all valid equivalence classes have been covered by test cases, write a new test case covering as many of the covered valid equivalence classes as possible.
      • Until all invalid equivalence classes have been covered by test cases, write a test case that covers one and only one of the uncovered invalid equivalence classes.
  3. Boundary value analysis: Boundary conditions are those situations directly on, above or beneath the edges of input equivalence classes and output equivalence classes. The author then gives guidelines for boundary value analysis:
    • If an input condition specifies a range of values, write test cases for valid ends of the range and invalid-input test cases for situations just beyond ends.
    • If an input condition specifies a number of values, write test cases for the minimum and maximum number of values and one beneath and beyond these values.
    • Try to create input conditions that test boundaries of output range and beyond.
    • Try to create input conditions that test boundaries of output values and beyond.
  4. Cause Effect Graphing: This technique can explore combinations of input circumstances. The author then describe a process to derive test cases using this method. The author then take an example and apply the method to derive test cases.
  5. Error Guessing: it is not possible to give exact procedure for this technique since it is intuition based or ad-hoc. The author then provides an example of how to guess errors.
The author then provides a final strategy which is a combination of the methods provided earlier as follows:
  1. Use Cause Effect Graphing from specification of input conditions.
  2. Use Boundary Value Analysis
  3. Identify valid and invalid equivalence classes for the input and output.
  4. Use error-guessing techniques to add additional test cases.
  5. Use decision coverage, condition coverage, multiple-condition coverage to meet coverage criterion.

No comments:

Post a Comment