Let’s take a simple abstract example: if(A && (B || C)), where AB, 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 to false).
    • Variables B and C in T1 must be equivalent (either both evaluate to true or both evaluate to false) to B and C in T2. In other words, B and C must have the same truth values in T1 and T2.
  • For condition B:
    • There must be one test case where B = true (say, T3).
    • There must be one test case where B = false (say, T4).
    • T3 and T4 must have different outcomes.
    • Variables A and C in T3 must be equivalent to A and C in T4.
  • For condition C:
    • There must be one test case where C = true (say, T5).
    • There must be one test case where C = false (say, T6).
    • T5 and T6 have different outcomes.
    • Variables A and B in T5 must be equivalent to A and B in T6.

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.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *