Definition
MC/DC
Modified Condition/Decision Coverage (MC/DC) is a rigorous structural testing metric that extends Decision Coverage. It requires that each atomic condition in a decision be shown to independently affect the decision’s outcome.
Requirements:
- Every atomic condition has taken all possible outcomes (True/False).
- Every decision (branch) has taken all possible outcomes (True/False).
- Each condition is shown to independently determine the result (changing only that condition changes the decision output).
All or Nothing
Unlike other metrics (e.g., “80% Statement Coverage”), MC/DC is typically considered binary. It is either fully achieved or not; partial coverage is rarely used as a metric.
Concept
MC/DC serves as a practical compromise between the insufficient testing of simple condition/branch coverage and the exponential complexity of testing all combinations of conditions.
- Efficiency: It requires test cases for a decision with conditions (linear complexity) instead of (exponential).
- Usage: It is mandated for safety-critical systems (e.g., avionics software).
Independence Pair
To prove that condition c independently affects the decision, we need a pair of test cases () such that:
- Condition c is True in and False in .
- All other conditions remain constant (have the same truth values in both tests).
- The outcome of the decision in is different from .
Example
Consider the decision if (A && (B || C)).
Truth Table Analysis:
| ID | A | B | C | Result |
|---|---|---|---|---|
| 1 | T | T | T | T |
| 2 | T | T | F | T |
| 3 | T | F | T | T |
| 4 | T | F | F | F |
| 5 | F | T | T | F |
| 6 | F | T | F | F |
| 7 | F | F | T | F |
| 8 | F | F | F | F |
Independence Pairs:
- For A:
- Needs to toggle (), others fixed, result toggles.
- Pairs: .
- (Note: is invalid because Result does not change).
- For B:
- Needs to toggle (), others fixed, result toggles.
- Pairs: .
- For C:
- Needs to toggle (), others fixed, result toggles.
- Pairs: .
Minimal Test Suite: To satisfy MC/DC, we select a subset of tests that cover at least one independence pair for every condition.
- Selected Set:
- A is covered by pair .
- B is covered by pair .
- C is covered by pair .
- Efficiency: We achieved full coverage with 4 tests () instead of the full 8 ().