Suppose that program P has been produced for known specification S. To test P, we run it with an input i and check to see that the output for i satisfies the specification for i. We can formalize this procedure by defining a test case to be a pair (i, S(i)). We expect P(i) = S(i). For an example, see Example 8.19.Test strategies falls into two categories:
- Black-box (or closed box) testing, in which test cases are derived from specification only.
- White-box (or open box) testing, in which the test cases are selected based on knowledge of internal program structure.
White-box testing includes statement (node) coverage and branch coverage, see Examples 8.20 and 8.21. Path coverage means covering each path, which normally is impossible (loops!). Simple path testing is a strategy requiring the execution of every simple path. Visit-each-loop testing is such that:
- branch coverage is satisfied
- for every loop, there are paths for which control flow both stright past the loop and around the loop at least once.
An infeasible path is program path that cannot be executed for any input, see Example 8.22.
Knowing the minimum number of test cases for some testing strategy can help when deriving test cases. A number of hierarchical measures for this are illustrated in Figures 8.15 and 8.16. The measures are given in Appendix 8.10.4.
Test effectiveness ratio can be defined as the ratio of certain objects covered by the test, see Example 8.29