Decision coverage technique comes under white box testing which gives decision coverage to Boolean values. This technique reports true and false outcomes of Boolean expressions. Whenever there is a possibility of two or more outcomes from the statements like do while statement, if statement and case statement (Control flow statements), it is considered as decision point because there are two outcomes either true or false.

Decision coverage covers all possible outcomes of each and every Boolean condition of the code by using control flow graph or chart.

Generally, a decision point has two decision values one is true, and another is false that's why most of the times the total number of outcomes is two. The percent of decision coverage can be found by dividing the number of exercised outcome with the total number of outcomes and multiplied by 100.

Decision Coverage technique in whitebox testing link

In this technique, it is tough to get 100% coverage because sometimes expressions get complicated. Due to this, there are several different methods to report decision coverage. All these methods cover the most important combinations and very much similar to decision coverage. The benefit of these methods is enhancement of the sensitivity of control flow.

We can find the number of decision coverage as follows.

Let's understand it by an example.

Consider the code to apply on decision coverage technique:

  1. Test (int a)    
  2. {   
  3. If(a>4)   
  4. a=a*3   
  5. Print (a)   
  6. }   

Scenario 1:
Value of a is 7 (a=7)

  1. Test (int a=7)   
  2. if (a>4)   
  3. a=a*3   
  4. print (a)   
  5. }   

The code highlighted in yellow is executed code. The outcome of this code is "True" if condition (a>4) is checked.

Control flow graph when the value of a is 7.

Decision Coverage technique in whitebox testing link

Calculation of Decision Coverage percent:

Decision Coverage technique in whitebox testing link
  1. Decision Coverage = ½*100  (Only "True" is exercised)  
  2.                     =100/2  
  3.                     = 50  
  4. Decision Coverage is 50%   

Scenario 2:
Value of a is 3 (a=3)

  1. Test (int a=3)   
  2. if (a>4)   
  3. a=a*3   
  4. print (a)   
  5. }  

The code highlighted in yellow will be executed. The outcome of this code is ?False? if condition (a>4) is checked.

Control flow graph when the value of a is 3

Decision Coverage technique in whitebox testing link

Calculation of Decision Coverage percent:

Decision Coverage technique in whitebox testing link
  1. = ½*100  (Only "False" is exercised) <br>  
  2. =100/2   
  3. 50  
  4. Decision Coverage = 50%  

Result table of Decision Coverage:

 

Test Case

Value of A

Output

Decision Coverage

1

3

3

50%

2

7

21

50%