Modified Condition/Decision Coverage

Modified Condition Decision Coverage (MCDC) is a coverage type that makes sure every condition within a decision determines every possible outcome of that decision. This coverage type is a good combination of effectiveness (good coverage) and efficiency (not too many test cases). 

This coverage type can be used in various test design techniques as shown in this picture: 

Condition-oriented test design techniques

 

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.

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

MCDC is the standard coverage type for the test design techniques Semantic Testing and Elementary Comparison Testing

Where Semantic testing focuses on testing individual decision points, Elementary comparison testing is used for testing functionality that consists of multiple decision points. 

This text gives an overview of MCDC, Semantic Testing and Elementary Comparison Testing.  

This building block first describes MCDC and then describes how MCDC is used to design test cases with Semantic Testing and with Elementary Comparison Testing. 

The following example will be used to explain the use of the coverage type and test design techniques: 

Example

Last year, QualityLand opened Agile Water Paradise. This is an outdoor water area that, besides a swimming pool, offers several attractions, such as: the Crazy Conditions River, the Magic Boat Ride, Shoot-the-chute and the Giant Waves Pool. 

Since it is outdoor, this area is only open from May to September, with one exception: at Halloween (October 31st) this area is also open for a special event, the Super-Duper Masked Water Party (which was a huge success, last year). 

At first, tickets for Agile Water Paradise could only be purchased as an addition to QualityLand tickets. However, market research learned that selling separate tickets for Agile Water Paradise would add great business value. Therefore, new functionality must be implemented to make this possible. 

The functionality for the online purchase of separate tickets has been described as follows: 

When ordering online, the customer first chooses a date for the visit to Agile Water Paradise. If a date is chosen on which Agile Water Paradise is closed, the following message should appear: “Unfortunately, Agile Water Paradise is closed on the date of your choice. Please choose another date.” 

If a valid date is chosen, the customer can enter the number of tickets, QualityLand discount card number (if applicable) or Student card number (if applicable). The customer can also check the box for attending the daily Summer Splash Party at the Giant Waves Pool for which an additional fee must be paid. This additional fee also applies to the Super-Duper Masked Water Party at Halloween. For the latter, the fee is automatically added when the chosen date is the date of Halloween. 

 The price per ticket is calculated as follows: 

IF    (chosen date ≥ May AND chosen date ≤ September) OR chosen date = October 31st 
THEN    IF (QualityLand discount card OR Student card) AND number of tickets > 4 
THEN    price per ticket = € 15.00 
ELSE    price per ticket = € 17.50 
ENDIF 

IF    chosen date = October 31st OR Summer Splash Party = Y 
THEN    price := price + € 3.50 
IF    number of tickets ≥ 10 
THEN   discount of 10% 
ENDIF 

ELSE   no additional fee 
ENDIF 

ELSE   message: “Unfortunately, Agile Water Paradise is closed on the date of your choice. Please choose another date.” 
ENDIF 

Application of MCDC 

Modified Condition Decision Coverage (MCDC) is a coverage type, from the coverage group Condition-oriented test design, that ensures that every possible outcome of a condition at least once is the determinant of the outcome of the decision. 

MCDC implies condition coverage (CC), decision coverage (DC) and condition decision coverage (CDC). 

The important concept in this definition is "determinant". If the outcome of the condition changes (from true to false or vice versa) then the outcome of the whole decision point changes with it.  

If a decision point consists of the conditions A, B and C (or more), 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. 

In other words: changing only the value of A from TRUE to FALSE changes the outcome of the decision from TRUE to FALSE (and vice versa). 

      The same applies to all other conditions in the decision point. 

MCDC is a thorough level of coverage. The big advantage of this coverage type is its efficiency: if a decision point 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 at least once. Then all the other conditions in that situation should be given a value that does not influence the outcome of the decision. This value is called the “neutral value” and is explained below. 

Neutral value explained 

Take, for example, a decision (R), that consists of a combination of two conditions (A, B). 

Let’s first have a look at a decision for which the outcome of the decision is only TRUE if both conditions are TRUE. In other words:  

R = A AND B 

What MCDC aims to achieve is defining test situations in such a way that the outcome of the decision changes by only changing the value of A. And then by only changing the value of B. (And if there were more conditions, this would apply to every condition.) 

Note: TRUE is represented by 1 and FALSE is represented by 0. 

Let’s concentrate on condition A being the determinant of the outcome: we want to change the outcome of the decision by only changing the value of A. 

Since we only want to change the value of A, we are looking for a ‘neutral’ value for B: the same value for B in every test situation in which A is the determinant. 

Test situation 1: A = 0 AND B = ? → R = 0 

If A = 0, for the outcome to be FALSE, B can either be 1 or 0. 

Test situation 2: A = 1 AND B = ? → R = 1 

If A = 1, for the outcome to be TRUE, B can only be 1. 

Hence, the only value for B that we can use in both test situations is 1. So, if the operator is AND, the neutral value for B is 1. 

Now what is the neutral value if the operator is OR? The decision now is only FALSE if both conditions are FALSE: 

R = A OR B 

Since we only want to change the value of A, we are looking for a ‘neutral’ value for B: the same value for B in every test situation in which A is the determinant. 

Test situation 1: A = 1 OR B = ? → R = 1 

If A = 1, for the outcome to be TRUE, B can either be 1 or 0. 

Test situation 2: A = 0 OR B = ? → R = 0 

If A = 0, for the outcome to be FALSE, B can only be 0 

Hence, the only value for B that we can use in both test situations is 0. If the operator is OR, the neutral value for B is 0. 

Summarized: 
Neutral value with AND:    1 
Neutral value with OR:    0 

6-step plan for deriving test situations for MCDC

To apply MCDC, every condition in the decision point must be the determinant once. If a condition is the determinant this means that changing the value of only that condition from TRUE to FALSE changes the outcome of the decision from TRUE to FALSE (and vice versa). Every other condition must then be given a neutral value. So,

  • 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.  

Example

IF chosen date = October 31st OR Summer Splash Party = Y 

THEN price := price + € 3.50 

ELSE no additional fee 

ENDIF 

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: Date = October 31st    
B: Summer Splash Party = Y    

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: Date = October 31st  . .  . .
B: Summer Splash Party = Y  . .   . . 

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: Date = October 31st  1 .  0 .
B: Summer Splash Party = Y  . 1   . 0 

The MCDC template you can download here is an excel-template in which steps 1-4 have been applied already. 

Step 5

Over the remaining dots, enter a neutral value.
In this case, both A and B are connected through the operator OR. So for both, the neutral value is 0. 

R = A or B 1 0
A: Date = October 31st  1 0  0 0
B: Summer Splash Party = Y  0 1   0 0 

Step 6

Score out duplicates of test situations. 

R = A or B 1 0
A: Date = October 31st   1 0  0 0
B: Summer Splash Party = Y  0 1   0 0 

We have this template available to support you to make you test specification.

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 composite decision point, however complex. With composite decision points 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 the second decision point from the example: 

Example

IF (QualityLand discount card OR Student card) AND number of tickets > 4 

THEN price per ticket = € 15.00 

ELSE price per ticket = € 17.50 

In short, this can be written as: 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  (€ 15.00 )  0 (€ 17.50 )
A: QualityLand discount card  1 . .   0 . . 
B: Student card  . 1 .   . 0 . 
C: Number of tickets > 4  . . 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 "0 1" is selected for (A OR B) AND C (where C is the determining value), then after the 6 steps, the table looks as follows

R = (A or B) and C  1  (€ 15.00 )   0 (€ 17.50 )
A: QualityLand discount card  1 0 1   0 0 1 
B: Student card  0 1 1   0 0 1 
C: Number of tickets > 4  0 1 1   1 0 0 

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

In Quality for DevOps teams, and the syllabus for TMAP: High-Performance Quality Engineering the coverage type MCDC and the test design techniques Semantic testing and Elementary Comparison Testing are combined.

Read here how these techniques are to be used in a combined way.