^

Modified Condition/Decision Coverage (MC/DC) in embedded software

Modified Condition/Decision Coverage (MC/DC) is a software testing concept that originated the rigorous testing of critical embedded software systems in the aviation industry. It is a structural coverage metric that specifically addresses those instances where the exhaustive testing of all possible combinations of conditions would be impractical.

The concept of MC/DC has since been adopted in other industries where software reliability is paramount. It is recommended for the highest safety integrity levels in functional safety standards typified by IEC 61508 and its derivatives including ISO 26262 for automotive software and IEC 62304 for medical devices. As a further example of its popularity, NASA mandates 100% MC/DC coverage for safety-critical software components.

 

What are multiple condition decisions?

Multiple condition decision statements are such that the outcome depends on the evaluation of two or more conditions. These conditions are typically combined using logical operators such as AND, OR, and NOT. For example, a decision statement like if (A AND B) OR C is a multiple condition decision because the outcome depends on the values of conditions A, B, and C.

For example, the decision in this code has 6 conditions:

Compound Condition Coverage (exhaustive testing) and multiple condition decisions

Exhaustive testing is sometimes impractical. It can take a lot of tests to ensure that all possible paths through a multiple condition decision have been exercised. MC/DC coverage is designed to alleviate that, and it does not require every possible combination to be executed. If “n” is the number of conditions, then a minimum of “n + 1” combinations are required to achieve 100% coverage, as opposed to 2n total combinations.

What is Modified Condition/Decision Coverage (MC/DC)?

Modified Condition/Decision Coverage (MC/DC) is a software testing criterion that ensures each condition within a decision statement independently influences the decision’s outcome. Formally, MC/DC requires that:

  • Each condition in a decision has been shown to independently affect that decision’s outcome.
  • Each condition has been tested in such a way that it can be demonstrated that changing the condition’s value alone can change the decision’s result.

What does MC/DC stand for?

MC/DC is an abbreviation for Modified Condition/Decision Coverage.

When is Modified Condition/Decision Coverage (MC/DC) required?

Exhaustive testing is practical where there are 3 or less conditions. For 4 or more, Modified Condition/Decision Coverage (MC/DC) becomes a far more practical solution.

How is Modified Condition/Decision Coverage MC/DC applied in practice?

Applying Modified Condition/Decision Coverage (MC/DC) from first principles involves five key steps:

  1. Identify Decision Points: Identify all the decision points in the software under test where multiple conditions influence the outcome.
  2. List Conditions: For each decision point, list all the individual conditions that contribute to the decision.
  3. Create Test Pairs (or Independence Pairs): Develop test pairs for each condition. Each pair should differ in only one condition, demonstrating that changing this single condition can change the decision’s result. In practice, the development of test pairs is not always an easy or intuitive process. Automation helps!
  4. Execute Tests: Run the test pairs to verify that each condition independently affects the decision’s outcome.
  5. Analyse Results: Review the test results to ensure that all conditions have been tested independently and that the software behaves as expected under all scenarios.

What are MC/DC test (or independence) pairs?

MC/DC test pairs (also known as independence pairs) are pairs of test cases designed to demonstrate that each condition in a decision statement independently affects the decision’s outcome.

Which standards require the use of Modified Condition/Decision Coverage (MC/DC) for embedded software?

Many standards call for the use of MC/DC, particularly for the most critical of embedded systems. Examples include:

DO-178C and Modified Condition/Decision Coverage (MC/DC)

In the civil aviation sector, DO-178C §6.4.4.2 requires that “test coverage of software structure is achieved”, with Table A-7 making clear that “modified condition/decision coverage” is required for Software Level A (DAL A).

IEC 61508 and Modified Condition/Decision Coverage (MC/DC)

For electronic safety-related systems generally, IEC 61508 Part 3 §7.4.7 and §7.4.8 discuss software module and integration testing. Table B-2 details which techniques are to be used according to criticality.

That table specifies “Structural test coverage (conditions, MC/DC) 100%” with the proviso that “where 100% coverage cannot be achieved…an appropriate explanation should be given”.

ISO 26262 and Modified Condition/Decision Coverage (MC/DC)

In the automotive sector, ISO 26262 Part 6 §9.4.4 requires that “structural coverage shall be measured in accordance with the metrics in Table 9″. Table 9 shows that MC/DC is “recommended” for ASIL A-C, and “highly recommended” for ASIL D.

NASA NPR 7150.2D and Modified Condition/Decision Coverage (MC/DC)

In the space sector, NPR 7150.2D §3.7.4 states that “If a project has safety-critical software, the project manager shall ensure that there is 100 percent code test coverage using the Modified Condition/Decision Coverage (MC/DC) criterion for all identified safety-critical software components.”

Modified Condition/Decision Coverage (MC/DC) analysis from LDRA

LDRA MC/DC analysis is available with both the TBrun component of the LDRA tool suite, and the LDRAunit stand-alone, point product tool for automated unit test generation and management.

TBrun and LDRAunit can each leverage the TBextreme add-in to automatically generate test cases that provide 50-80% of coverage, and their intuitive test case building environment lets developers quickly augment those test cases to increase their coverage if necessary.

Each condition needs a pair of tests to prove that when that condition changes in isolation, then the output changes. To achieve MC/DC coverage for n conditions requires a minimum of (n+1) tests. For example, if there are 6 conditions, at least 7 tests will be required.

Clear, concise reporting presents a truth table showing which pairs could be used for each condition, highlights the combinations that hit the greatest number of independent pairs, and indicates which combinations constitute a complete minimal test set.

Additional information and training materials

Modified Condition/Decision Coverage (MC/DC) – free pdf downloads

Modified Condition/Decision Coverage (MC/DC) – further information

FREE 30 Day
TRIAL

Email Us

Email: info@ldra.com

Call Us

EMEA: +44 (0)151 649 9300

USA: +1 (855) 855 5372

INDIA: +91 80 4080 8707

Connect with LDRA