DC vs. CC vs. CDC vs. MC/DC

The "Code Coverage Types" parent page uses an example where not all code coverage types reveal their logical differences. This page provides an additional example to highlight these differences.

Consider a decision with two conditions: (A or B)

Decision Coverage (DC)

The below inputs satisfy the coverage. They toggle the decision outcome between true and false.

  1. (TRUE/FALSE) --> True branch

  2. (FALSE/FALSE) --> False branch

triangle-exclamation

As such, the above set of cases do not distinguish between the decision (A or B) and just A.

Condition Coverage (CC)

The below inputs satisfy the coverage. Both A and B use both outcomes.

  1. (TRUE/FALSE) --> True branch

  2. (FALSE/TRUE) --> True branch still

We can now confirm that B does have an effect.

triangle-exclamation

Condition/Decision Coverage (CDC)

Combination of the previous two types. Both A and B outcomes are used, and both branches are reached.

  1. (TRUE/TRUE) --> True branch

  2. (FALSE/FALSE) --> False branch

triangle-exclamation

Modified Condition/Decision Coverage (MC/DC)

This coverage type requires a more thoughtful test case selection, and, in general, a min of n+1 cases, where n is the number of conditions in a decision. For (A or B), we need 2+1 = 3 tests.

  1. (TRUE/FALSE) --> True branch

  2. (FALSE/TRUE) --> True branch

  3. (FALSE/FALSE) --> False branch

circle-check

Note that it is not always possible to follow MCDC "expectations". Among other things, MCDC mandates that each condition has been shown to independently affect that decision's outcome.

In other words, you must be able to toggle A value, while keeping all others constant.

But bear in mind that you often have exceptional compound decisions such as:

It has 4 atomic conditions, where the 1st A and the 2nd A are two separate conditions. Strictly speaking, you can't toggle the 1st A without toggling the 2nd A. But in practice - that's fine.

Last updated