6

When using the White Box method of testing called Multiple Condition Coverage, do we take all conditional statements or just the ones with multiple conditions? Now maybe the clues in the name but I'm not sure.

So if I have the following method

void someMethod()
  {

      if(a && b && (c || (d && e)) )  //Conditional A
      {

      }

      if(z && q)   // Conditional  B
      {
      }

  }

Do I generate the truth table for just "Conditional A", or do I also do Conditional B?

Thanks,

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Robben_Ford_Fan_boy
  • 8,494
  • 11
  • 64
  • 85
  • Looks more like the code executed by Conditional A and the that by Conditional B should be in different methods that get tested independantly – CaffGeek Jul 16 '10 at 14:08

2 Answers2

1

I might be missing something here but, the way you wrote the code in your question, conditions A and B are completely independent of each other. You therefore won't cover all of the code unless you test both conditionals.

gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
  • Yep - it won't. But it's more the term multip[le-condition-coverage that I'm referring to - specifically does the term just apply to A or B – Robben_Ford_Fan_boy May 18 '10 at 06:56
  • My understanding of multiple condition coverage is that all combinations of conditions inside each decision are tested, which implies that you need it whenever there are two or more values being tested. That means condition B would qualify in my book. – gareth_bowles May 18 '10 at 15:22
1

I found the following on Multiple condition coverage. This would seem to indicate that Multiple Condition Coverage, as the name suggests, only applies to conditionals with multiple statements.

So for the following conditional:

if ((a>0)&&(b<=4)&&(c>0))

We create the following

Test Case   a > 0   b <= 4    c > 0
MCC1        F        F         F
MCC2        F        F         T
MCC3        F        T         F
MCC4        F        T         T
MCC5        T        F         F
MCC6        T        F         T
MCC7        T        T         F
MCC8        T        T         T
Robben_Ford_Fan_boy
  • 8,494
  • 11
  • 64
  • 85