The statement coverage strategy aims to design test cases so that every
statement in a program is executed at least once. The principal idea governing
the statement coverage strategy is that unless a statement is executed, it is very
hard to determine if an error exists in that statement. Unless a statement is
executed, it is very difficult to observe whether it causes failure due to some
illegal memory access, wrong result computation, etc. However, executing some
statement once and observing that it behaves properly for that input value is no
guarantee that it will behave correctly for all input values.
Example: Consider the Euclid’s GCD computation algorithm:
int compute_gcd(x, y)
{
int x, y;
while (x! = y){
if (x>y) then
x= x – y;
else
y= y – x;
}
return x;
}
By choosing the test set {(x=3, y=3), (x=4, y=3), (x=3, y=4)}, we can exercise the
program such that all statements are executed at least once.
Thus we can conclude that (S1) is FALSE.
The path-coverage testing does not require coverage of all paths but only coverage of linearly independent paths.The path coverage-based testing strategy requires us to design test cases such that all linearly independent paths in the program are executed at least once.
Linearly independent path ( WRT Control Flow Graph )
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.
Thus (S2) is TRUE.
C) is the answer.