Page 210 - DCAP405_SOFTWARE_ENGINEERING
P. 210
Unit 12: Testing Tactics
3. Determine a basis set of linearly independent paths. The value of V(G) provides the number Notes
of linearly independent paths through the program control structure. In the case of
procedure average, we expect to specify six paths:
path 1: 1-2-10-11-13
path 2: 1-2-10-12-13
path 3: 1-2-3-10-11-13
path 4: 1-2-3-4-5-8-9-2-. . .
path 5: 1-2-3-4-5-6-8-9-2-. . .
path 6: 1-2-3-4-5-6-7-8-9-2-. . .
The ellipsis (. . .) following paths 4, 5, and 6 indicates that any path through the remainder
of the control structure is acceptable. It is often worthwhile to identify predicate nodes as
an aid in the derivation of test cases. In this case, nodes 2, 3, 5, 6, and 10 are predicate nodes.
4. Prepare test cases that will force execution of each path in the basis set. Data should be
chosen so that conditions at the predicate nodes are appropriately set as each path is tested.
Test cases that satisfy the basis set just described are:
Path 1 test case: value(k) = valid input, where k < i for 2 = i = 100
value(i) = -999 where 2 = i = 100
Expected results: Correct average based on k values and proper totals.
Note: Path 1 cannot be tested standalone but must be tested as part of path 4, 5, and 6 tests.
Path 2 test case: value(1) = -999
Expected results: Average = -999; other totals at initial values.
Path 3 test case: Attempt to process 101 or more values. First 100 values should be valid.
Expected results: Same as test case 1.
Path 4 test case: value(i) = valid input where i < 100
value(k) < minimum where k < i
Expected results: Correct average based on k values and proper totals.
Path 5 test case: value(i) = valid input where i < 100
value(k) > maximum where k <= i
Expected results: Correct average based on n values and proper totals.
Path 6 test case: value(i) = valid input where i < 100
Expected results: Correct average based on n values and proper totals.
Each test case is executed and compared to expected results. Once all test cases have been completed,
the tester can be sure that all statements in the program have been executed at least once.
It is important to note that some independent paths (e.g., path 1 in our example) cannot be tested
in stand-alone fashion. That is, the combination of data required to traverse the path cannot be
achieved in the normal flow of the program. In such cases, these paths are tested as part of
another path test.
LOVELY PROFESSIONAL UNIVERSITY 203