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:
IF A+B > 50 THEN
If A+B<50 THEN
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.
So Decision or Branch Coverage is 2.
Example 2 :
Suppose you have a if statement like
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.