Professional Documents
Culture Documents
22 Validation Testing Path
22 Validation Testing Path
Technique: Generate a test case for every possible (acyclic) path in the program flow graph
CE202 Software Engineering, 2011-12 1 Dr Amnon H. Eden, School of Computer Science and Electronic Engineering, University of Essex 2
Code coverage II
Program flow graph:
Nodes: Blocks of statements Edges: Potential transitions
Branching: Whenever there is more than one transition from the same node
If statements For/while statements Switch statements Dynamically-bound method calls (in O-O programs)
{ // 1 // 2 // // // // 3 4 5 6
// 7 // 8
1, 2, 3, 4, 6, 7 (,2) 1, 2, 3, 4, 5, 7 (,2)
T
4
3
elemArray [mid] != key
F
5 elemArray [mid]< key 6
Test cases should be derived so that all of these paths are executed A dynamic program analyser may be used to check that paths have been executed
6
7 9
1
i=0
2
elemArray [i] < key
True
False
4
elemArray [i] == key
3
return -1
True
5
return i 7 8
Code-coverage of loops
Conclusion: there are (practically) infinitely-many possible paths within each loop. Question: Which paths should we test? Answer: Only two
While loop: Zero and one iterations For loop: One and two iterations