You are on page 1of 19

Different types of coverage in White Box testing

Coverage types
1) 2) 3) 4) 5) Statement coverage Branch coverage Path coverage LCSAJ coverage Condition coverage
(i) Basic conditions coverage (ii) Modified condition / Decision coverage

Statement coverage
Every statement of the program should be exercised at least 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?

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 the statement?

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 the statement?

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.

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 and 100% statement coverage

Path coverage
Every execution path of the program should be exercised at least once.

LCSAJ coverage:
A Linear Code 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 is transferred at the end of the linear sequence.

Condition coverage
Each condition in a branch is made to evaluate to true and false at least once (Basic condition). All possible combinations of condition outcomes within each branch should be exercised at least once (MC/DC).
Condition coverage Modified condition / Decision coverage (MC/DC)

Basic condition coverage

Example for Condition 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?

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); }

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.

Few more example


Read p Read q IF p+q > 100 THEN Print "Large" ENDIF IF p > 50 THEN Print "p Large" ENDIF

Few more example


If x=3 then Display_messageX; If y=2 then Display_messageY; Else Display_messageZ; Else Display_messageZ;

Few more example


IF A > B THEN C=AB ELSE C=A+B ENDIF Read D IF C = D Then Print Error ENDIF

Any more clarification Required?

Thank you

You might also like