Tutorials Hut

• # What is Decision Coverage Testing ?

Decision coverage is the measuring percentage of decision outcomes tested (e.g. the True and False options of the IF statement).This technique comes under white box testing which gives decision coverage to Boolean values. It is also known as branch coverage or all-edges coverage or edge testing.

DecisionCoverage covers all possible results of  every Boolean condition of the code by using control flow graph or chart.

It aims to ensure that each one of the possible branch from each decision point is executed.

• Similar to branch testing and control flow testing
• DecisionCoverage is always stronger than statement coverage
• 100% decisionCoverage guarantees 100% statement coverage, but not vice versa
• 100% branch coverage implies 100% decisionCoverage.
• DecisionCoverage measures the coverage of conditional branches.
• It assures that every decision (true/false) in the source code has been executed and tested.
• DecisionCoverage also known as branch coverage or all-edges coverage or edge testing.
• It covers both the true and false conditions unlikely the statement coverage.

Decision testing is a form of control flow testing as it creates a specific flow of control through the decision points.

`Decision Coverage = (No of Decision outcome exercised)/ (total No of Decision Outcomes)`

#### Example of Decision Coverage:

`Read A  Read B  IF A+B > 50 THEN  Print "Large"  ENDIF  If A+B<50 THEN  Print "Small"  ENDIF`

To calculate Branch Coverage, we have to find minimum number of paths so that all the edges should be covered.

and there is  no single path which will ensure coverage of all the edges at once.

for covering all possible true/false decisions.

(1) 12-4-5-6-8

(2)1-3-5-7

So Decision or Branch Coverage is 2.

Example 2 :

Suppose you have a if statement like

`if(x>0)print "Postive";elseprint "Negative";`

Run this code with x=1 will result in 100% coverage but only True Decision is covered so for 100% DecisionCoverage you need to run a test case with x=-1 to cover the False Decision as well.

### Advantages of decision coverage:

• To validate that all the branches in the code are reached.
• To ensure that no branches lead to any abnormality of the program’s operation.
• It eliminate problems that occur with statement coverage testing.

• ### Testing Foundation

• Scroll to Top

Automated page speed optimizations for fast site performance