Friday, September 27, 2019

Achieve Effective Test Coverage

In spite of the fact that testing cannot prove correctness, it is still important to do a through job testing. Metrics exist to determine how thoroughly the code was exercised during test plan generation or test execution. These metrics are easy to use, and tools exist to monitor the coverage level of tests. Some examples include:
  1. Statement coverage, which measures the percentage of statements that have been executed at least once.
  2. Branch coverage, which measures the percentages of branches in a program that have been executed.
  3. Path coverage, which measures how well the possible paths have been exercised.
Just remember that, although "effective" coverage is better than no coverage at all, do not fool yourself into thinking that the program is "correct" by any definition (see Testing Exposes Presence of Flaws).


Reference:
Weiser, M., Gannon, J., and McMullin, P., "Comparison of Structural Test Coverage Metrics," IEEE Software, March 1985.