Statement and Decision Coverage...
Coverage:
1.
Statement
Coverage:
A statement may be on a single line, or it may be spread over several lines. One line may contain more than one statement. Some statements can contain other statements inside them
Example:
IF A > B THEN
C = A – B
ELSE
C = A + B
ENDIF
Read D
IF C = D Then
Print “Error”
ENDIF
For the above example we have one IF statement and IF statement contain s another 3 statements and one read statements, and then one IF statement, but the IF statement contains another statement (print) so totally nine statements
Let’s analyze the coverage of a set of tests on our nine-statement program:
Set 1
Test1.1: A=2, B=3, D=5
Test1.2: A=3, B=2, D=5
To find which statements have we covered (100%)
· In Test1.1 will cover the statements on lines 1,3,4,5,6,7,8,9
· In Test 1.2 will cover the statements on lines 1,2,5,6,7,9
We will have exercised all nine of the statements, so now statements coverage=100%, totally 2 tests need to achieve 100% Statement Coverage
2.
Decision
Coverage
A decision is an IF statements, a loop statement (e.g. DO-WHILE or REPEAT-UNTIL) or a CASE statement, where there are two or more possible exists or outcomes from the statement.
With an IF statement, the exit can either be TRUE or FALSE, depending on the value of the logical condition that comes after IF
Decision Coverage is calculated by
(Number of Decision outcomes exercised / total number of Decision
outcomes)*100
In the earlier just two test cases was required to achieve 100% statement coverage. However, decision coverage requires each decision to had both a True and False outcome
Let’s analyze the coverage of a set of tests on our 2 condition program (same above example):
Test Set 2
Test2.1: A=2, B=3, D=5
Test2.2: A=3, B=2, D=5
This now covers both decision outcomes,
· Test 2.1 False with A>B condition and True with C=D decision
· Test 2.2 True with A>B condition and False with C=D decision
We will have exercised all the 2 condition, now Decision coverage=100%, totally 2 tests need to achieve 100% Decision Coverage
“100% Decision Coverage implies 100% Statement Coverage”

