Important announcement

Dear visitor,

Please note that this OpenCourseWare platform will be replaced at the end of 2026 by a new platform (under the same url ocw.tudelft.nl).

Courses and their contents that are currently available the platform will partly be migrated. URL’s for this content will change and content might be unavailable for some time. In addition, some courses will not be available anymore.

If you are linking to specific courses on this platform (for instance for your students), please take timely measures to avoid problems with access. Possible actions are:

  • Download the materials to your local platform (laptop, server)
  • For educators only (including TU Delft lecturers): Contact us at ocw@tudelft.nl and inform us what course you are using in what context (institute, program, period of use, number of students). We will research (in collaboration with the authors of the course) and decide if we will migrate the course, and if yes, can supply you with a new url.

Thank you.

3.4.3 Another MC/DC example

Course subject(s) Module 3. Structural Testing and Code Coverage

MC/DC requires practice. Let’s do one more example. Let’s suppose the expression we want to test is: (A && B) || C. 

That’s the truth table:

Truth table for (A & B) | C

Let’s start with condition A. We have tests 2 and 6.

  • If we flip A in row 1 (TTT), the counterpart is row 5 (FTT). As the outcome of both are the same TRUE, tests 1 and 5 are not able to evaluate the outcome of A independently of the other conditions.
  • If we flip A in row 2 (TTF), the counterpart is row 6 (FTF). As the outcomes are different, tests 2 and 6 are able to evaluate the outcome of A independently of the other conditions. We keep them.
  • We keep flipping. Row 3 and its counterpart 7 are not able to independently evaluate A, as their outcomes are the same.
  • Row 4 and its counterpart 8 are not able to independently evaluate A, as their outcomes are the same.

Let’s look at condition B. We have tests 2 and 4.

  • If we flip B in row 1 (TTT), the counterpart is row 3 (TFT). Outcomes are the same.
  • If we flip B in row 2 (TTF), the counterpart is row 4 (TFF). Outcomes are different, so tests 2 and 4 are able to evaluate B independently of the other conditions.
  • We keep flipping. Row 5 and 7 have the same outcomes.
  • Rows 6 and 8 have the same outcomes.

Now, let’s look at C. If you repeat the same procedure, you will find three possible pairs: (3, 4), (5,6) and (7,8).

Now, if we try to minimize the number of tests (after all, we know that we need N+1 tests, where N is the number of conditions, thus, 4 tests), we have two options:

  • 2, 3, 4, 6. So, A is tested by 2 and 6, B is tested by 2 and 4, and C is tested by 3 and 4.
  • 2, 4, 5, 6. So, A is tested by 2 and 6, B is tested by 2 and 4, and C is tested by 5 and 6.

Good!

Now, an exercise for you: can you expand this idea to a problem that is not boolean? Let’s suppose you are calculating the price of your product, and you have the following decision table:

Decision table for the new problem

Can you apply MC/DC here? We’ll discuss this in future weeks.

Creative Commons License
Automated Software Testing: Practical Skills for Java Developers by TU Delft OpenCourseWare is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://online-learning.tudelft.nl/courses/automated-software-testing-practical-skills-for-java-developers/.
Back to top
[sg_popup id=6]