Software Testing-2
Software Testing-2
2 3
2
4
4
CFG of the program…
Example: Consider the following program:
int compute_gcd( int x, int y) {
1 while (x! = y){
2 if (x>y)
3 x= x – y;
4 else y= y – x;
5 }
6 return x;
}
Fig 1: CFG of the GCD algorithm
1
3 4
6
What is Path?
A path through a program is a node and edge sequence from
the starting node to a terminal node of the control flow graph
of a program. There can be more than one terminal node in a
program. Writing test cases to cover all the paths of a typical
program is impractical. For this reason, the path-coverage
testing does not require coverage of all paths but only
coverage of linearly independent paths.
What is Linearly independent path?
A linearly independent path is any path through the program
that introduces at least one new edge that is not included in
any other linearly independent paths. If a path has one new
node compared to all other linearly independent paths, then the
path is also linearly independent.
???
Control flow graph: In order to understand the path coverage-
based testing strategy, it is very much necessary to understand
the control flow graph (CFG) of a program.