8/6/2019 Coverage in White Box Testing
1/19
Different types of coverage in
White Box testing
8/6/2019 Coverage in White Box Testing
2/19
Coverage types
1) Statement coverage
2) Branch coverage
3) Path coverage4) LCSAJ coverage
5) Condition coverage
(i) Basic conditions coverage(ii) Modified condition / Decision coverage
8/6/2019 Coverage in White Box Testing
3/19
Statement coverage
Every statement of the program should be exercised atleast once
Eg 1.
Main(){
Int a,b;
Scanf(%d%d,&a,&b)
Printf(a is big);
Ptintf(b is big);
}
How many test case required to cover the statement?
8/6/2019 Coverage in White Box Testing
4/19
Statement coverage Eg. Con
Main()
{
Int a,b;
Scanf(%d%d,&a,&b)
If(a>0)
{
Printf(a is big);
Ptintf(b is big);
}}
How many number of test cases required to cover thestatement?
8/6/2019 Coverage in White Box Testing
5/19
Statement coverage Eg. Con
Main()
{
Int a,b;
Scanf(%d%d,&a,&b)If(a>b)
Printf(a is big);
Else
Ptintf(b is big);}
How many number of test cases required to cover thestatement?
8/6/2019 Coverage in White Box Testing
6/19
Branch Coverage
or
Decision Coverage
Every possible alternative in a branch (or,decision) of the program should be
exercised at least once.
For if statements this means that the
branch must be made to take on the
values true and false.
8/6/2019 Coverage in White Box Testing
7/19
Branch Coverage (or) Decision
Coerage Eg.Main(){
Int a,b;
Scanf(%d%d,&a,&b)
If(a>100)Printf( statement 1);
Else if ((a>=50) || (b==10))
Printf( statement 2);
Else
Printf( statement 3);
}How many number of test cases required to cover the Branch?
So branch coverage implies both 100% decision coverage and100% statement coverage
8/6/2019 Coverage in White Box Testing
8/19
Path coverageEvery execution path of theprogram should be exercised at
least once.
8/6/2019 Coverage in White Box Testing
9/19
LCSAJ coverage:
A LinearCode Sequence And Jump,
consisting of the following three items
(conventionally identified by line numbers
in a source code listing): the start of the
linear sequence of executable statements,
the end of the linear sequence, and the
target line to which control flow istransferred at the end of the linear
sequence.
8/6/2019 Coverage in White Box Testing
10/19
8/6/2019 Coverage in White Box Testing
11/19
8/6/2019 Coverage in White Box Testing
12/19
Example forCondition coverage
Main()
{
Int a,b;
Scanf(%d%d,&a,&b)
If(a>100)
Printf( statement 1);
Else if ((a>=50) || (b==10))
Printf( statement 2);
Else
Printf( statement 3);
}How many number of test cases required for basic condition and
MC/DC?
8/6/2019 Coverage in White Box Testing
13/19
How many number of test cases required for
statement , Branch, Basic condition and
MC/DC coverage?void main(void)
{
int a, b, c;
scanf("%d %d %d", a, b, c);
if ((a > 1) && (b == 0))
b = c / a;
if ((a == 2) || (c > 1))
c = c + 1;
while (a >= 2)a = a - 2;
printf("%d %d %d", a, b, c);
}
8/6/2019 Coverage in White Box Testing
14/19
Conclusion
branch coverage implies both 100%
decision coverage and 100% statement
coverage
100% LCSAJ coverage implies 100%
decision coverage.
100% decision coverage implies both 100%
branch coverage and 100% statement
coverage.
8/6/2019 Coverage in White Box Testing
15/19
Few more example
Read p
Read q
IF p+q > 100 THENPrint "Large"
ENDIF
IF p > 50 THEN
Print "p Large"
ENDIF
8/6/2019 Coverage in White Box Testing
16/19
Few more example
If x=3 then
Display_messageX;
If y=2 thenDisplay_messageY;
Else
Display_messageZ;
Else
Display_messageZ;
8/6/2019 Coverage in White Box Testing
17/19
Few more example
IF A > B THEN
C = A B
ELSE
C = A + B
ENDIF
ReadD
IF C = D Then
PrintError
ENDIF
8/6/2019 Coverage in White Box Testing
18/19
Any more clarification Required?
8/6/2019 Coverage in White Box Testing
19/19
Thank you