# Modified Condition/Decision Coverage

##### Definition:

Modified condition/decision coverage (MCDC) is the coverage type that guarantees the following:

Every possible outcome of a condition is the determinant of the outcome of the decision at least once.

The important concept in this definition is "determinant". If the outcome of the condition changes (from 0 to 1 or vice versa) then the outcome of the whole decision point changes with it. The meaning of MCDC can be explained as follows:

If a decision point consists of the conditions A, B and C, then MCDC guarantees:

• That there is at least 1 test situation in which the outcome is TRUE, owing to the fact that condition A is TRUE
• That there is at least 1 test situation in which the outcome is FALSE, owing to the fact that condition A is FALSE
• The same goes for all other conditions in the decision point.

This is a thorough level of coverage, with which the following faults, for example, would be detected in the system under test:

• There is a condition missing that should be present
• The “AND” was wrongly implemented as an “OR”, and vice versa
• A condition has been inverted, such as “<” instead of “>” or “≠” instead of “=”.

The big advantage of this coverage type is its efficiency: with a decision point that consists of N conditions, usually only N+1 test situations are required for MCDC. Compared with the maximum number of test situations (the complete decision table) of 2N , that is a considerable reduction, particularly if N is large (complex decision points). This combination of “thorough coverage” with “relatively few test situations” makes this coverage type a powerful weapon in the tester’s arsenal.

According to the definition of MCDC, every condition should determine the outcome of the decision once. Then all the other conditions in that situation should be given a value that has no influence on the outcome of the decision. This value is called the “neutral value” and is further explained below.

##### In more detail:

Take, for example, the complex decision (R), which consists of a combination of two conditions (A, B). The outcome of the decision is only true if both conditions are true. In other words:
R = A AND B

Now suppose that condition B is FALSE (or value 0). Then it no longer matters what A is; the outcome of R is always FALSE. In other words:
A AND 0 = 0

However, if condition B is TRUE (or value 1), the R outcome of the decision depends entirely on the outcome of A. In other words:
A AND 1 = A

This last is exactly what should be achieved with MCDC:
If condition A should determine the outcome of the decision (in this 'AND combination'), then the other condition should be set at value 1. We are talking here about the neutral value, since value 1 has no influence on the final outcome.
Similarly, we can talk of the neutral value for the 'OR combination', which is 0 in this case, since:
A OR 0 = A

In summary:
The neutral value with AND = 1
The neutral value with OR = 0

#### 6-step plan for deriving test situations for MCDC

Employing the concept of "neutral value", achieving MCDC can be translated in concrete terms into the requirements:

• Let every condition within the decision be TRUE once and FALSE once,
• With all the other conditions in that test situation being given a neutral value.

There are various ways of deriving the necessary test situations. The 6-step plan is a technique that very directly follows on the definition of MCDC and with which a table is simply created with all the necessary test situations. The 6-step plan is explained below with a relatively simple example. Subsequently, it is explained how this technique works for more complex combinations of conditions.

Take as an example the following decision point, which describes how good customers receive an extra discount:
IF (Number of books > 8 OR Sum ≥ €250) THEN extra discount

The decision point here is made up of 2 conditions with the structure: R = A OR B.
The 6-step plan is set out below, giving the test situations with which this decision point is covered by MCDC.

Step 1

Create a table with 3 columns and fill in the first row as follows:

 R = A or B 1 0

Step 2

Add 1 row for every condition in the decision.
This row will contain the 2 test situations in which the relevant condition determines the outcome of the decision point. The condition will decide the outcome "1" once and the outcome "0" once.
In the first column, enter the description of every condition.

R = A or B 1 0
A: number of books > 8
B: Sum => EUR 250

Step 3

Fill in the rest of the cells in the table with a number of dots equal to the number of conditions in the decision.
Each cell is a test situation, which should indicate which combination of TRUE/FALSE applies to the conditions.

R = A or B 1 0
A: number of books > 8  . .  . .
B: Sum => EUR 250  . .   . .

Step 4

Enter "1" diagonally in the second column and "0" in the third column.
This is actually entering the determining values for every condition. The meaning of e.g. the cell that belongs to row "A" and column "1" is: "This is the test situation in which condition A determines an outcome of 1."

R = A or B 1 0
A: number of books > 8  1 .  0 .
B: Sum => EUR 250  . 1   . 0

Step 5

Over the remaining dots, enter a neutral value.
In this case, both A and B will contribute to the outcome via an OR combination. So for both, the neutral value is 0.

R = A or B 1 0
A: number of books > 8  1 0  0 0
B: Sum => EUR 250  0 1   0 0

Step 6

Score out duplicates of test situations.

R = A or B 1 0
A: number of books > 8  1 0  0 0
B: Sum => EUR 250  0 1   0 0

##### In more detail:

Each test situation can be further worked out, by indicating which requirements are set on the parameters of the decision point to arrive in this test situation. This is particularly useful if the tester is dealing with many decision points and so with many test situations that have to be combined into test cases.
In the above example, the 3 test situations can be worked out as follows:

Test situations 10 01 00
A: number of books  > 8  <=8 <=8
B: Sum   < EUR 250   => EUR 250  < EUR 250

The 6-step plan described above works for every compound condition, however complex. With compound conditions in which both "AND" and "OR" occur, care should be taken at step 5 (entering the neutral values). The example below will explain this.

Take as an example the decision point R = (A OR B) AND C. After the first 4 steps, the table of test situations looks as follows:

R = (A or B) and C  1   0
A  1 . .   0 . .
B  . 1 .   . 0 .
C  . . 1   . . 0

Now the neutral values should be entered for each of the 6 situations. With the top 2 situations (A is the determining value), the neutral values can immediately be determined: B is connected to A via the operator "OR" and should therefore be given the neutral value "0". C is connected with A via the operator "AND" and should therefore be given the neutral value "1".

The same applies to the middle 2 situations (B is the determining value). However, for the bottom situation (C is the determining value) an interim step is necessary: it is not A that is directly connected with C, nor is it B. It is the combination "(A OR B)" that is connected with C, via the operator "AND". Thus "(A OR B)" should assume the neutral value of "AND", and that is "1". In other words: (A OR B) = 1. For the values for A and B there are 3 possibilities of achieving this, i.e. "1 1", "1 0" or "0 1". Only 1 of the 3 need to be selected to reach the goal of MCDC. In principle, it does not matter which. The only difference in the 3 possibilities is that in selecting "1 0" or "0 1" a test situation can be scored off, while that is not possible with the choice of "1 1".
If the neutral value of "1 0" is selected for (A OR B), then after the 6 steps, the table looks as follows:

R = (A or B) and C  1   0
A  1 0 1   0 0 1
B  0 1 1   0 0 1
C  1 0 1   1 0 0

This phenomenon, that several possibilities exist for neutral values, always occurs in cases of an operator between brackets.