0

Recently, I started working on software testing, and I had some questions.

Pairwise testing is the combination of all the values that this parameter can have, and is it also applicable to Boolean Expression?

For example,

boolean expression is (A || B) && C (It is assumed that each parameter has only 0 and 1.)

Here, Is it applicable to Boolean Exp ??

The second question is about MC/DC.

I had learned how to make test case through MC/DC

But, I wondered how MC/DC could prove to cover almost 90% code coverage ?

In (A || B) && C, there are 4 combination test case in my guess.

But, All combination is 8. how could MC/DC reduce cases ?

2 Answers 2

0
  1. Is it applicable in Boolean expressions?

Yes. It's applicable to Boolean expressions.

Truth Table

Getting all possible combinations of your Boolean expression, we can have the truth table above.


  1. How could MC/DC prove to cover almost 90% code coverage?

MC/DC can't assure over 90% code coverage. However, it can assure the decision, branch, and condition coverages, which are integral parts of a piece of code.

But, how could it prove to cover?

The answer will lie in the properties of the MC/DC criterion:

  • Each condition in a Boolean expression should take every possible outcome.
  • Each decision takes every possible outcome.
  • Each condition is shown to independently affect the outcome of the decision.

So each condition's Boolean outcome has been considered (TRUE/FALSE) and the combination of these condition's Boolean outcome (decision) will result in every possible value (TRUE/FALSE).


  1. How could MC/DC reduce cases?

When you identify MC/DC pairs, you will come up with this table:

MC/DC Pairs

Some of these pairs are similar. Why? Because when you evaluate the Boolean expression, you can short-circuit some of the conditions. This means that your expression can have a decision even if at least one of the conditions are not being evaluated.

Final MC/DC Test Cases

This will be the final result. Notice that some of the rows have (-) empty values. This means that it wasn't evaluated, but the decision can be inferred.


Although relevant, but unrelated, I wrote an article here: How MC/DC Can Speedup Unit Test Creation

Hope this helps despite being late. :D

2
  • I also had a question related to this. For example if I had condition like: if ( ( a == 1 ) && ( ( b == 2 ) || ( b == 3 ) ||( b == 4 ) ) ), then how many test cases shall I required to achieve full MC/DC coverage? Commented Nov 15, 2019 at 8:28
  • @user2995743 in your case for example, you can achieve full MC/DC with n+1. since you have 4 different conditions (b==1 is not the same as b==2, and so on), you will need at least 5 cases to have full coverage
    – arjayosma
    Commented Nov 17, 2019 at 23:35
0

MC/DC tests help in discovering dead code. To get MC/DC coverage 100% each change in input should affect the output.

For condition "(A || B) && C", there are 3 inputs: minimum 4 test cases required (n+1).

A B C: Y 1 0 1: 1 1 0 0: 0 ( C changed from 1st test) 0 0 1: 0 ( A changed from 1st test) 0 1 1: 1 ( B changed from 3rd test)

MC/DC test does not confirm that code is correctly implemented as (A || B) && C. If a concatenated input is used, for example "(A or B) and (not(A) or C). not(A) should be considered as another input. So a minimum of 5 test cases are required.

Not the answer you're looking for? Browse other questions tagged or ask your own question.