Professional Documents
Culture Documents
MC/DC Testing
This lecture is based on Safety critical software development and testing techniques available
on open literature. It is suitable for M.Tech ( Avionics) students.
MC/DC Testing DO 178 B
MC/DC is defined in DO-178B/ED-12B, -“Software Considerations in Airborne Systems and
Equipment Certification”, dated December 1, 1992.
Definition of MC/DC:
(1) Every point of entry and exit in the program has been invoked at least once
(2) Every condition in a decision in the program has taken all possible outcomes at least once
(3) Every decision in the program has taken all possible outcomes at least once
(4) Each condition in a decision has been shown to independently affect that decision's
outcome. A condition is shown to independently affect a decision's outcome by varying just
that condition while holding fixed all other possible conditions.
Decision Coverage
Decision coverage requires two test cases: one for a true outcome and another for a false
outcome.
For simple decisions (i.e., decisions with a single condition), decision coverage ensures
complete testing of control constructs. But, not all decisions are simple. For the decision (A or
B), test cases (TF) and (FF) will toggle the decision outcome between true and false. However,
the effect of B is not tested; that is, those test cases cannot distinguish between the decision (A
or B) and the decision A.
Condition Coverage
Condition coverage requires that each condition in a decision take on all possible outcomes at
least once (to overcome the problem in the previous example), but does not require that the
decision take on all possible outcomes at least once. In this case, for the decision(A or B) test
cases (TF) and (FT) meet the coverage criterion, but do not cause the decision to take on all
possible outcomes. As with decision coverage, a minimum of two tests cases is required for
each decision.
Condition/decision coverage combines the requirements for decision coverage with those for
condition coverage. That is, there must be sufficient test cases to toggle the decision outcome
between true and false and to toggle each condition value between true and false. Hence, a
minimum of two test cases are necessary for each decision. Using the example (A or B), test
cases (TT) and (FF) would meet the coverage requirement. However, these two tests do not
distinguish the correct expression (A or B) from the expression A or from the expression B or
from the expression (A and B).
Finally, multiple condition coverage requires test cases that ensure each possible combination
of inputs to a decision is executed at least once; that is, multiple condition coverage requires
exhaustive testing of the input combinations to a decision. In theory, multiple condition
coverage is the most desirable structural coverage measure; but, it is impractical for many
cases. For a decision with n inputs, multiple condition coverage requires 2n tests.
MC / DC criteria is stronger than Condition /Decision.
100% MC/DC will gurantee that each simple condition will not be masked by the other
condition. For Example a situation as X < 0 Or Y < 0 then if X= -1 then X<0 is true , and
condition Y<0 is masked since it is always true irrespective of Y condition.
Testing Criterias
if ( ( A ||B) && C)
{ /* stmt 1
} else
{ /* stmt 2
Here A, B and C represent atomic boolean expressions (i.e. not divisible in other
boolean sub-expressions).
In order to ensure Condition coverage criteria for this example, A, B and C should be
evaluated at least one time "true" and one time "false" during tests, which would be the
case with the 2 following tests:
A = true / B = true / C = true
A = false / B = false / C = false
Besides, Decision and Condition coverage criteria are still respected (each boolean
variable and the decision's outcome itself take at least one time the "true" and "false"
values). The Modified condition/decision coverage is then ensured.
Example 2
Assume we replace the condition: ((A||B)&&C)
by: (((u == 0) || (x>5)) && ((y<6) || (z == 0)))
A full Test Coverage would consist into building the following truth table and testing
each combination: