Reputation: 87
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
):
Decision coverage will have only one test (the result will be TRUE
):
Do I understand that right?
Upvotes: 7
Views: 12905
Reputation: 39
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:
A = true | B = not eval | C = false
A = false | B = true | C = true
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:
A is evaluated to true
A is evaluated to false and B is evaluated to true
A and B are evaluated to false
Upvotes: 3
Reputation: 19
Example:
print("Zero")
print("Positive")
print("Negative")
Here the Statement no. 2, 4 and 6 will be considered under Condition Coverage. (Bcz here you are checking the condition that is it equal to 0 or not, is it greater than 0 or not, etc.)
and the statement no. 3, 5 and 7 will be considered under Decision coverage. (Bcz these are the decision taken after cheking the condition)
Imp Note: Decision Coverage and Branch Coverage are different.
Upvotes: 1