Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Condition coverage vs Decision coverage testing

Tags:

testing

What is the difference between Condition coverage and Decision coverage?

I have a simple example:

IF (A && B) THEN

Condition coverage will have two tests (the result will be FALSE):

  1. A = TRUE, B = FALSE
  2. A = FALSE, B = TRUE

Decision coverage will have only one test (the result will be TRUE):

  1. A = TRUE, B = TRUE

Do I understand that right?

like image 500
Kos112567 Avatar asked Aug 10 '26 03:08

Kos112567


1 Answers

In Condition Coverage (also know as Predicate Coverage) each of the boolean expressions must be evaluated to true and false at least once. For example:

IF ((A || B) && C) THEN

To satisfy the condition coverage criteria, you could use the following tests:

  1. A = true | B = not eval | C = false

  2. A = false | B = true | C = true

  3. A = false | B = false | C = not eval

In Decision Coverage (also know as Branch Coverage) you have to test all posible branches. For example:

IF (A){
   ...
ELSE IF(B) {
   ...
} ELSE {
   ...
}

To satisfy the decision coverage criteria for this piece of code you'll need to run 3 tests:

  1. A is evaluated to true

  2. A is evaluated to false and B is evaluated to true

  3. A and B are evaluated to false

like image 84
Vitor Bona Avatar answered Aug 27 '26 04:08

Vitor Bona



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!