Test coverage has to do with testing certain attributes or pieces of the program, such as statement coverage or branch coverage or condition coverage or code coverage. This is impossible since the domain of inputs is too large and there are too many possible tests through a program.
Coverage measurement is a good tool to show how far you are from Complete Testing. But it is weirdly a lousy tool to measure how close you are to completion.
Models
- Statement Coverage
- Segment Coverage
- Branch coverage
- Condition coverage
- Condition/Decision coverage is considered by combining branch and condition coverage
- Modified condition/decision coverage
- The idea here is to test important combinations of conditions and limiting testing costs
- We extend branch and decision coverage with the requirements and each condition should affect the decision outcome independently
- Each condition should be evaluated one time to true and one time to false without affecting the decisions outcome
In general, loops are highly fault-prone so they need to be tested carefully. Every loop involves a decision to traverse the loop or not, including boundary value analysis. Nested loops need to be tested separately. For minimal coverage we should cover the loop 0, 1, and 2+ times. We should try the loop control variable with:
- min - 1
- min
- min + 1
- max - 1
- max
- max + 1
For nested loops, we start at the innermost loop, set all the outer loops to their minimum values, set all other loops to typical values, and repeat the above test to the inner loop, moving up one loop level every time. Then do cases for all loops in the nest simultaneously.