What is conditional coverage? Conditional coverage is a white-box testing method that measures the percentage of exercised branches in the code. Conditional coverage is a special case of test diversity.
Measure Conditional Coverage
Discover un-tested code
Improve Test Quality
Why conditional coverage? An un-exercised branch could contain a defect that will not be detected. An exercised branch increases the confidence that the branch contains no defects.
Conditional coverage is a special case of test diversity. For more information on test diversity and the benefits of diversity over code coverage go to diversity.
Conditional coverage, also known as branch testing or decision coverage, measures the percentage of exercised conditional expressions in conditional statements, multi-branching statements, and/or loops. A conditional expression is covered when testing results in both true and false evaluation of the expression. For example, in the C statement:
if(x == 1 || y == 1)
the conditional expression x == 1 || y == 1 is completely conditionally covered with values 1 for x and 1 for y, and 0 for x and 0 for y. In a multi-branching statement, such as a switch statement in C++, conditional coverage measures the percentage of exercised branches in the multi-branching statement. A multi-branching statement is conditionally covered when all the branches get hit by testing. For example, in the C switch statement:
case 1: x=x+y;
case 2: x=x*y;
} choice=1 covers the case 1 branch, choice=2 covers the case 2 branch, and any other value for choice covers the default branch.
Conditional Coverage vs. Test Diversity
Test criteria, such as coverage criteria, neither make a distinction between the potential infinity of test suites that satisfy the given criteria nor they make a distinction between test suites that do not satisfy the given criteria. Typically, some of the large number of suits that satisfy a criterion detect defects while other suites that satisfy the criterion do not detect defects. And vice versa, some of the large number of suits that do not satisfy a criterion detect defects while other suites that do not satisfy the criterion do not detect defects.
Even if you obtain 100% branch coverage, or 100% of any other type of coverage, you could have done that in a restricted and concentrated manner with respect to control and data. Such concentrated coverage has no chance of detecting defects outside of this restricted area. Smaller the restricted area is smaller the chance are that all the defects in the code will be detected.
Regardless of the test criterion used or the reliability model used, test cases that yield similar control-flows and data-flows exercise the program in a restricted, confined, dependent, and concentrated manner, whereas test cases with different control flows and data flows increase the chance of defect detection by exercising the program in fundamentally different, dispersed, and independent ways.