Modified Condition/Decision Coverage (MC/DC) is a code coverage criterion used in software testing. It requires that each condition in a decision has been shown to independently affect the decision's outcome. MC/DC ensures that each condition within a complex decision statement is tested with all possible outcomes at least once, and each condition must be shown to be able to independently affect the outcome of the decision.
For the given equation:
output = (i1 || i2) && i3 || (i4 ^ i5)
We need to create test cases that ensure MC/DC coverage. For each condition i1, i2, i3, i4, i5, we must show that it can independently affect the output. The ^ operator represents the logical XOR operation in your equation.
Let's break down the conditions and decision points:
- Condition 1 (C1):
(i1 || i2)
- Condition 2 (C2):
i3
- Condition 3 (C3):
(i4 ^ i5)
Each condition will have a pair of test cases that demonstrate its ability to independently affect the decision's outcome. We will also make sure that only one condition changes between these test cases to demonstrate the independence of that condition.
Here are the test cases to achieve MC/DC coverage for the given equation:
TC# | i1 | i2 | i3 | i4 | i5 | (i1 || i2) | (i4 ^ i5) | output | Condition Changed
----|----|----|----|----|----|------------|------------|--------|-------------------
1 | F | F | T | F | T | F | T | T | C1
2 | T | F | T | F | T | T | T | T | C1
3 | F | T | T | F | T | T | T | T | C1
4 | F | F | T | T | F | F | T | T | C1
5 | F | F | F | F | T | F | T | T | C2
6 | F | F | T | F | T | F | T | T | C2
7 | F | F | F | T | F | F | T | T | C3
8 | F | F | F | F | F | F | F | F | C3
In this table:
T stands for true.
F stands for false.
- The "Condition Changed" column indicates which condition is being tested for independence in each pair of test cases.
Note that we have created test case pairs for each condition such that within a pair, only one input changes, which demonstrates the independence of that condition in affecting the outcome. MC/DC requires such pairs for each condition within the decision.
This table does not necessarily show the minimal set of test cases for MC/DC but is instead illustrative of the pairs needed to demonstrate the independence of conditions. In practice, you can often achieve MC/DC with fewer test cases by carefully choosing the conditions that change. It is also possible to achieve MC/DC coverage with a set of test cases where each condition is shown to independently affect the decision's outcome without having to explicitly list all pairs, as long as each condition's effect is demonstrated.