engineers who test safety critical
software are often confronted with a
test coverage metric called mcdc
in this video you will learn
what is mcdc
why is mcdc used
and
what can i do if my requirements-based
test cases do not achieve full mcdc
first what is mcdc
mcdc which stands for modified condition
decision coverage is a structural
coverage metric
structural coverage analysis measures
how much of your design has been tested
two common forms of structural coverage
are decision and condition coverage
mcdc extends decision and condition
coverage by requiring that each
condition should independently affect
the decision outcome
in other words
mcdc shows how a given input
independently affects the output of a
logical expression
here is a simple example to explain the
concept
this model has an or gate and gate and a
switch with three boolean inputs a b and
c
and integer output y
to achieve full mcdc we need to develop
test vectors that ensure that each of
the inputs independently affects the
output
we can write the test case in a test
sequence block
the test sequence initializes all three
inputs to false which sets output y to
negative one
in step one let's hold inputs a and b to
false and set input c to true output y
will remain negative one
in step two
let's set input b to true
this will set output y to one and we'll
demonstrate how input v independently
affects the output
in step 3
let's demonstrate how input c
independently affects output y
we can do this by setting input c to
false this will set output y to negative
1.
the only remaining step is to
demonstrate how input a independently
affects output y
to do this
let's set input a to true and input b to
false
this will set output y to 1.
when combined with step 1
this demonstrates how input a
independently affects the output
this simple example shows how to achieve
full mcdc by holding certain inputs
constant to show how a given input
independently affects the output of a
logical expression
why is mcdc used
standards such as d0178 and iso 26262
require full mcdc for software developed
to the highest criticality level when
you achieve full mcdc you will have
tested each condition in your design
at a time that it mattered
when it affects the output of an
expression
this can improve the effectiveness and
efficiency of your tests
what can i do if my requirements-based
test cases don't achieve full mcdc
for each uncovered objective you should
ask
why does this condition not affect the
outcome
first look at the collected coverage to
see if there are any errors in your
design
this might take the form of dead logic
how would these errors affect how the
uncovered objective affects the output
of the expression
second
look for opportunities to augment your
existing requirements-based test cases
make sure to update the expected results
if necessary and be sure the
traceability to requirements is valid
third
the uncovered objective may be the
result of a derived requirement
a derived requirement in this case is a
part of your design which is not the
direct result of a higher level
requirement
a best practice is to document and write
test cases for these derived
requirements
finally if you are sure none of the
above applies you can justify the
missing coverage after analyzing its
impact on the design
you can then filter out specific
coverage objectives during testing
in general you can consider justifying
missing coverage for logic that you did
not intend to exercise in your current
testing context
a common example of this is dead logic
due to defensive coding practices
it is important that the justification
rationale be clear in case the design is
modified in the future
or if the testing context changes
you can use simulink design verifier to
check for dead logic before simulating
your models
the tool can show you which mcdc
objectives are unreachable and can
automatically create a filter for
unreachable or dead objectives
you can also use simulink design
verifier to automatically generate test
vectors
you can simulate these test vectors to
understand how to achieve full mcdc
to learn more visit the simulink
coverage product page on mathworks.com