Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

testing

What is Modified Condition/Decision Coverage?

Amaaz Ahmad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Modified Condition/Decision Coverage (MC/DC) is a method used in software testing to test highly critical systems.

MC/DC requires that all possible states of each condition must be tested while keeping other conditions fixed. Moreover, the change in an individual condition must be shown to alter the result.

Below are the four conditions to fulfill the requirements of MC/DC:

  • Each exit and entry point of the program must be executed in at least one of the test cases.
  • Every decision is tested for all possible outcomes.
  • Each condition in a decision is tested for all possible states.
  • Each individual condition must be shown to alter the result independently.

A condition is a boolean expression that cannot be divided further. A decision is a combination of conditions and boolean operators.

Example

Consider the following snippet of code in C++:

#include <iostream>
using namespace std;
int main() {
bool a = false, b = true, c = false;
if(a && b || c){
cout << "Inside the IF block" << endl;
}
}

In the above snippet of code, we have three boolean variables (conditions). Below is the truth table, which shows all possible values of those variables and the result of the boolean expression (decision) in line 7 of the above snippet:

Test No.

a

b

c

a && b || c

1

0

0

0

0

2

0

0

1

1

3

0

1

0

0

4

0

1

1

1

5

1

0

0

0

6

1

0

1

1

7

1

1

0

1

8

1

1

1

1

Both possible states (0/1) of each variable have been tested in the above table while keeping the other two variables constant. Moreover, the decision produced by these conditions is in both possible outcomes at least once.

Test numbers 0 and 1 show that the variable c can alter the result independently while keeping the other two variables fixed. Test numbers 5 and 7 show that b can independently alter the value of the result. Test numbers 3 and 7 show that a can independently alter the result. Hence, we will choose test numbers 0, 1, 3, 5, and 7 as our test cases.

RELATED TAGS

testing

CONTRIBUTOR

Amaaz Ahmad
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring