Modified condition/decision coverage
Modified condition/decision coverage (MC/DC) is a code coverage criterion used in software testing.
Overview
MC/DC requires all of the below during testing:[1]
- Each entry and exit point is invoked
- Each decision takes every possible outcome
- Each condition in a decision takes every possible outcome
- Each condition in a decision is shown to independently affect the outcome of the decision.
Independence of a condition is shown by proving that only one condition changes at a time.
MC/DC is used in avionics software development guidance DO-178B and DO-178C to ensure adequate testing of the most critical (Level A) software, which is defined as that software which could provide (or prevent failure of) continued safe flight and landing of an aircraft. It is also highly recommended for SIL 4 in part 3 Annex B of the basic safety publication[2] and ASIL D in part 6 of automotive standard ISO 26262.[3]
Definitions
- Condition
- A condition is a leaf-level Boolean expression (it cannot be broken down into simpler Boolean expressions).
- Decision
- A Boolean expression composed of conditions and zero or more Boolean operators. A decision without a Boolean operator is a condition.
- Condition coverage
- Every condition in a decision in the program has taken all possible outcomes at least once.
- Decision coverage
- Every point of entry and exit in the program has been invoked at least once, and every decision in the program has taken all possible outcomes at least once.
- Condition/decision coverage
- Every point of entry and exit in the program has been invoked at least once, every condition in a decision in the program has taken all possible outcomes at least once, and every decision in the program has taken all possible outcomes at least once.
- Modified condition/decision coverage
- Every point of entry and exit in the program has been invoked at least once, every condition in a decision in the program has taken all possible outcomes at least once, and each condition has been shown to affect that decision outcome independently. A condition is shown to affect a decision's outcome independently by varying just that condition while holding fixed all other possible conditions. The condition/decision criterion does not guarantee the coverage of all conditions in the module because in many test cases, some conditions of a decision are masked by the other conditions. Using the modified condition/decision criterion, each condition must be shown to be able to act on the decision outcome by itself, everything else being held fixed. The MC/DC criterion is thus much stronger than the condition/decision coverage.
Criticism
Purely syntactic rearrangements of decisions (breaking them into several independently evaluated conditions using temporary variables, the values of which are then used in the decision) which do not change the semantics of a program can lower the difficulty of obtaining complete MC/DC coverage.[4] This is because MC/DC is driven by the program syntax. However, this kind of "cheating" can be done to simplify expressions, not simply to avoid MC/DC complexities. For example, assignment of the number of days in a month (excluding leap years) could be achieved by using either a switch statement or by using a table with an enumeration value as an index. The number of tests required based on the source code could be considerably different depending upon the coverage required, although semantically we would want to test both approaches with a minimum number of tests.
RC/DC
Reinforced condition/decision coverage (RC/DC) is a stronger version of the MC/DC coverage criterion, suitable for safety-critical systems.[5] It was originally proposed by Sergiy Vilkomir in 2002.[6]
A second publication refutes this claim and indicates that MCDC (at least the Unique Cause Strong MCDC "UCMS" or Masking) variants of MCDC have superior coverage to the referenced Reinforced condition/decision coverage (RC/DC).
See also
- Elementary Comparison Testing
References
- Hayhurst, Kelly; Veerhusen, Dan; Chilenski, John; Rierson, Leanna (May 2001). "A Practical Tutorial on Modified Condition/ Decision Coverage" (PDF). NASA.
- IEC 61508-3:2010
- ISO 26262-2011 Part 6 Table 12
- Rajan, Ajitha; Heimdahl, Mats; Whalen, Michael (March 2003). "The Effect of Program and Model Structure on MC⁄DC Test Adequacy Coverage" (PDF). Cite journal requires
|journal=
(help) - Vilkomir, S.A.; Bowen, J.P. (2006). "From MC/DC to RC/DC: formalization and analysis of control-flow testing criteria". Formal Aspects of Computing. 18 (1). Springer Nature. pp. 42–62. doi:10.1007/s00165-005-0084-7.
- Vilkomir, S.A.; Bowen, J.P. (2002). "Reinforced condition/decision coverage (RC/DC): A new criterion for software testing". International Conference of B and Z Users. Lecture Notes in Computer Science. 2272. Springer-Verlag. pp. 291–308. doi:10.1007/3-540-45648-1_15.
7. Kapoor, Kalpesh & Bowen, Jonathan. (2005). A formal analysis of MCDC and RCDC test criteria. Softw. Test., Verif. Reliab.. 15. 21-40. 10.1002/stvr.306