In: Computer Science
SE 4367, Software Testing
Homework #10, Control Flow Coverage
For the following program P written in pseudo-code, given the test set T: T = {t1 = <4, 2>, t2 = <90, 0>, t3 = <56, 1>}
Program P
4) if ((X≥0 AND X≤100)AND(Y>0 AND Y<4))
5) {
6) Z = -1;
7) if (X < 60)
8) {
9) Z = 0;
10) if (X > 80 AND Y == 1) 11) Z = 59;
12) Z = Z + 3;
13) }
14) else // !(X<60)
15) {
16) Z = 61;
17) if (Y == 0)
18) Z = 99;
19) else
20) Z = 62;
21) Z = Z + 1;
22) } // end else !(X<60)
a- Statement Coverage is a white box testing technique in which all the executable statements in the source code are executed at least once. It is used for calculation of the number of statements in source code which have been executed. The main purpose of Statement Coverage is to cover all the possible paths, lines and statements in source code.
So, Statement coverage = (no of executed statements/total no of statement)*100.
So, For t1=<4,2>,
statement coverage = (16/28)*100=57.14%
So, For t2=<90,0>,
statement coverage = (8/28)*100=28.57%
So, For t1=<56,1>,
statement coverage = (16/28)*100=57.14%
b-Block coverage testing is done to ensure that blocks of code aren't left untested by failing to test all paths of a conditional statement.
So, For t1=<4,2>,
block coverage = (2/7)*100=28.57%
So, For t1=<90,0>,
block coverage = (1/7)*100=14.28%
So, For t1=<56,1>,
block coverage = (2/7)*100=28.57%
c-Decision Coverage is a white box testing technique which reports the true or false outcomes of each boolean expression of the source code. The goal of decision coverage testing is to cover and validate all the accessible source code by checking and ensuring that each branch of every possible decision point is executed at least once.
decision coverage=(no of decision outcome excercised/total no of decision outcomes).
So, For t1=<4,2>,
decision coverage = (2/7)*100=28.57%
So, For t1=<90,0>,
decision coverage = (1/7)*100=14.28%
So, For t1=<56,1>,
decision coverage = (2/7)*100=28.57%
d-In condition coverage, one of the Boolean expression have been evaluated to both TRUE and FALSE.
So, in t1=<4,2> , 1st if condition is evaluated true followed by the nested if block inside the same. Rest all if and else will be evaluted false as they don't satisfy the required condtion.
Now, in t2=<90,0>, only the outer else condtion is evaluated true while all the rest conditions are false.
Again in t3=<56,1>, st if condition is evaluated true followed by the nested if block inside the same. Rest all if and else will be evaluted false as they don't satisfy the required condtion.
e- explained above in c& d.