Let’s take a simple abstract example: if(A
&&
(B
||
C))
, where A
, B
, and C
all evaluate to booleans. MC/DC dictates the following:
- For condition
A
:- There must be one test case where
A
=
true
(say, T1). - There must be one test case where
A
=
false
(say, T2). - T1 and T2 (which we call independence pairs) must have different outcomes (for example, T1 makes the entire decision evaluate to
true
, and T2 makes the entire decision evaluate tofalse
). - Variables
B
andC
in T1 must be equivalent (either both evaluate totrue
or both evaluate tofalse
) toB
andC
in T2. In other words,B
andC
must have the same truth values in T1 and T2.
- There must be one test case where
- For condition
B
: - For condition
C
:
If conditions have only binary outcomes (that is, true
or false
), the number of tests required to achieve 100% MC/DC coverage is N + 1, where N is the number of conditions in the decision (as shown by Chilenski [2001]). Note that N + 1 is smaller than the total number of possible combinations (2N). So, to devise a test suite that achieves 100% MC/DC, we must create N + 1 test cases that, when combined, exercise all the combinations independently from the others.
Leave a Reply