Decision Coverage Testing



Software testing is broadly divided into white box and black box testing techniques. Under the white box testing, the data structures, algorithms, logic, flow and code of the software are validated. Decision coverage testing is one of the concepts under the white box testing. It is a technique whose objective is to confirm that all the decision results inside the program are working fine. It helps to confirm that all the decision conditions have been executed at least once.

What is Software Decision Coverage Testing?

The software decision coverage testing is a part of the white box testing. It is conducted by the developers to verify the total decision results in the program. It only deals with the boolean values, namely true or false to every boolean expression. In some scenarios wherever there are probabilities of two or many outcomes originating from the statements such as do while, if, and case, it is referred to as decision points as there are two outcomes either false or true.

The software decision coverage testing touches all possible results of every boolean condition in the code by taking the help of the control flow graph or flow chart. As a decision consists of mainly two values namely true or false, so for the majority of scenarios the total count of outcomes is two.

Formula to Calculate the Software Decision Coverage Percentage

The software decision coverage can be calculated by dividing the total count of results executed with the total count of decision results in the source code, and then multiplied by hundred.

Decision Coverage = (Total count of decision results executed / 
   Total count of decision results in the source code) * 100

It is difficult to obtain hundred percent coverage as in some occasions the decision expressions are not simple. As a result, there are numerous methods to calculate the decision coverage. These methods cover every combination and have similar characteristics like the decision coverage.

Example

Let us take an example of the below code snippet to determine the count of the decision coverage.

Input X and Y
   Z = X + Y
   IF Z > 100 
   THEN PRINT IT IS COMPLETED
   END IF
   IF X > 50
     THEN PRINT IT IS NOT COMPLETED
   END IF
END

Let us now calculate the decision coverage with the first test case, using the values X = 60, and Y = 60.

The flow chart of the above lines of code with the X = 60, and Y = 60 is shown below −

Software Decision Coverage

In the above flow chart, there are a total 4 decision results denoted by 1, 2, 3, and 4 in green. As per the first test case using the values values X = 60, and Y = 60, we would have 2 decision results executed denoted by 5, and 6 in blue. So as per the formula,

Decision Coverage = (Total count of decision results executed / 
   Total count of decision results in the source code) * 100

Decision Coverage = (2 / 4) * 100 = 50 %.

Let us now calculate the decision coverage with the second test case, using the values X = 40, and Y = 20.

The flow chart of the above lines of code with the X = 40, and Y = 20 is shown below −

Software Decision Coverage

In the above flow chart, there are a total 4 decision results denoted by 1, 2, 3, and 4 in green. As per the first test case using the values values X = 40, and Y = 20, we would have 2 decision results executed denoted by 5, and 6 in blue. So as per the formula,

Decision Coverage = (Total count of decision results executed / 
   Total count of decision results in the source code) * 100

Decision Coverage = (2 / 4) * 100 = 50 %.

Thus by considering both the test cases, we would have a total 4 decision results, and total 4(2+2) decision results executed. So the total decision coverage as per formula −

Decision Coverage = (Total count of decision results executed / 
   Total count of decision results in the source code) * 100

Decision Coverage = (4 / 4) * 100 = 100 %.

By creating the two test cases with the values X = 60, and Y = 60, and X = 40, and Y = 20, we have achieved 100 % of decision coverage.

Conclusion

This concludes our comprehensive take on the tutorial on Software Decision Coverage Testing. Weve started with describing what software decision coverage testing, formula to calculate the software decision coverage percentage, and an example to obtain the software decision coverage percentage. This equips you with in-depth knowledge of Software Decision Coverage Testing. It is wise to keep practicing what youve learned and exploring others relevant to Software Testing to deepen your understanding and expand your horizons.

Advertisements