MC/DC is the coverage level required for the most critical software. It requires showing that each condition in a decision changes the outcome on its own. Here is its definition, the method for building the tests, its variants, its pitfalls, and what the standards say about it.
MC/DC stands for Modified Condition/Decision Coverage. The tests must meet four requirements.
The first three requirements make up condition/decision coverage. The fourth makes the difference: a condition that never changes the outcome is either poorly tested or useless. For the vocabulary (decision, condition) and the comparison with the other levels, see coverage levels.
MC/DC was born in aerospace. DO-178B, published in 1992, required it for level A software, whose failure would have catastrophic consequences. DO-178C, which succeeded it in 2011, kept this requirement.
The idea is to come close to the confidence that testing every combination would give, without paying the price: the number of tests grows with the number of conditions, not as a power of two. John Chilenski and Steven Miller published the reference analysis in 1994.
MC/DC has since spread to other sectors: automotive, with ISO 26262, and industry, with IEC 61508.
A train controller applies the brakes when the train is moving and a door is open, or when an emergency stop is requested.
The decision contains three conditions:
speed > 0;door_open;emergency.It reads A && (B || C).
int brake(int speed, int door_open, int emergency)
{
if (speed > 0 && (door_open || emergency))
return 1; /* apply the brakes */
return 0;
}
| Row | A | B | C | Brake | Pairs |
|---|---|---|---|---|---|
| 1 | F | F | F | no | — |
| 2 | F | F | T | no | A with 6 |
| 3 | F | T | F | no | A with 7 |
| 4 | F | T | T | no | A with 8 |
| 5 | T | F | F | no | B with 7, C with 6 |
| 6 | T | F | T | yes | A with 2, C with 5 |
| 7 | T | T | F | yes | A with 3, B with 5 |
| 8 | T | T | T | yes | A with 4 |
T: true. F: false. Highlighted: the four selected rows.
A has three possible pairs: 2-6, 3-7 or 4-8. B has only one, 5-7, and so has C, 5-6. Rows 5, 6 and 7 are therefore required; adding row 2, or row 3, covers A.
brake(0, 0, 1) → 0; brake(50, 0, 0) → 0; brake(50, 0, 1) → 1; brake(50, 1, 0) → 1. That is N + 1 tests for three conditions.
If the code forgot the emergency stop (speed > 0 && door_open), the row 6 test would not brake and would fail.
In C, in row 2, B and C are not evaluated: A is false, and so is the decision. The 2-6 pair remains valid, because B and C have the same values in both tests; see short-circuit evaluation in C and C++.
For a decision with N conditions, MC/DC requires between N + 1 and 2N tests. Multiple condition coverage requires up to 2N.
| Conditions | MC/DC | Multiple condition |
|---|---|---|
| 2 | 3 to 4 | 4 |
| 3 | 4 to 6 | 8 |
| 5 | 6 to 10 | 32 |
| 10 | 11 to 20 | 1,024 |
| 20 | 21 to 40 | 1,048,576 |
These figures are per decision, for the "unique-cause" variant. The real cost is not the number of tests but their design: each test must come from a requirement, and each missing pair requires understanding why it is missing.
They differ in what the other conditions are allowed to do between the two tests of a pair.
Only the condition under study changes; the others keep their value. This is the original form, and the strictest. It becomes impossible when the same condition appears twice in the decision, like a in (a && b) || (!a && c).
Other conditions may change, if their change cannot affect the outcome: they are masked. In A && B, when A is false, B does not count. This variant handles repeated conditions; the aerospace certification authorities accept it (CAST-6 paper).
For languages with short-circuit evaluation, such as C and C++, a condition that is not evaluated is treated as masked. This variant follows the actual execution of the code.
The variants do not always give the same percentage on the same code. Check which one your tool applies, and that it is accepted on your project.
MC/DC does not test every combination: it shows the effect of each condition, with far fewer tests.
In critical software, coverage is measured on requirements-based tests. A missing pair points to an incomplete requirement, a forgotten test or a useless condition: it is not a reason to add a test with no requirement behind it.
ifFor DO-178C, ok = a && b; or return a || b; are decisions too. Not all tools count them.
Each added condition requires at least one more test and one more pair. A decision with eight conditions often deserves to be simplified.
A variable that appears twice in the same decision makes unique cause impossible: masking is needed, or the decision must be rewritten.
A pair proves something only if both tests check the expected result. Coverage measures what was executed, not what was checked.
MC/DC is required for the functions whose failure would be the most serious.
Required for level A software, in addition to decision and statement coverage. The DO-178C page
Recommended for all ASILs, and highly recommended for ASIL D. The ISO 26262 page
IEC 61508 and other functional safety standards list it too. All standards compared
In every case, whatever remains uncovered must be dealt with: by an additional test derived from a requirement, or by a written justification.
On an embedded target, this instrumentation uses more memory than statement instrumentation: it is one of the criteria for choosing a tool. The GCC compiler also measures MC/DC since version 14, with gcov; see Testwell CTC++ or gcov?
Testwell CTC++ measures MC/DC and multiple condition coverage of C and C++ code (Java as an option):
On video, by Verifysoft Technology GmbH: MC/DC and multicondition coverage ↗ (8 min).
TiCS takes in the coverage measured by Testwell CTC++ or by another coverage tool:
Because MC/DC starts from condition/decision coverage and modifies it: it adds the requirement that each condition show its effect on the outcome.
No. It guarantees that each condition has been tested in a situation where it decides the outcome. A wrong requirement, a faulty calculation or a test that checks nothing still get through.
The standard sets the level. Multiple condition coverage tests every combination and quickly becomes unrealistic beyond four or five conditions; MC/DC delivers most of its value for a number of tests that stays reasonable.
MC/DC then amounts to decision coverage: two tests, one where it is true, the other where it is false.
Yes, since GCC 14: the code is compiled with the -fcondition-coverage option, and gcov produces the report. For a comparison with a dedicated tool, especially on an embedded target, see Testwell CTC++ or gcov?
Where the standard requires it, everything that is not covered must be dealt with, by a test or by a justification. Elsewhere, MC/DC is kept for the code whose failure would have the most serious consequences.
A free trial of Testwell CTC++ on your own C or C++ code, on the host or on the embedded target.
Code coverage · Coverage levels · Testwell CTC++ · DO-178C · Standards · Learn
Sources: Kelly J. Hayhurst, Dan S. Veerhusen, John J. Chilenski and Leanna K. Rierson, A Practical Tutorial on Modified Condition/Decision Coverage (NASA/TM-2001-210876, 2001) ↗; John J. Chilenski and Steven P. Miller, Applicability of Modified Condition/Decision Coverage to Software Testing (Software Engineering Journal, 1994); Certification Authorities Software Team, CAST-6, Rationale for Accepting Masking MC/DC in Certification Projects; GCC, Invoking gcov ↗.