software-engineering testing

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:

  1. Every atomic condition has taken all possible outcomes (True/False).
  2. Every decision (branch) has taken all possible outcomes (True/False).
  3. 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:

  1. Condition c is True in and False in .
  2. All other conditions remain constant (have the same truth values in both tests).
  3. The outcome of the decision in is different from .

Example

Consider the decision if (A && (B || C)).

Truth Table Analysis:

IDABCResult
1TTTT
2TTFT
3TFTT
4TFFF
5FTTF
6FTFF
7FFTF
8FFFF

Independence Pairs:

  1. For A:
    • Needs to toggle (), others fixed, result toggles.
    • Pairs: .
    • (Note: is invalid because Result does not change).
  2. For B:
    • Needs to toggle (), others fixed, result toggles.
    • Pairs: .
  3. 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 ().