用于覆盖MC DC的测试用例的可能组合数

时间:2013-08-02 13:34:13

标签: unit-testing testing code-coverage

例如表达式Z:=(A而不是B)或(C xor D); 以下是唯一可能的测试用例组合吗?

   testCaseNO  1 2 3 4 5
      Input A  T T F F F 
      Input B  T F T T T 
      Input C  F F F F T 
      Input D  F F F T F 
     Output Z  F T F T T 

或者以下给出MCDC也可以正常工作?

   testCaseNO  1 2 3 4 5
      Input A  T T T F F 
      Input B  T F T T F 
      Input C  F F T F T 
      Input D  F F T T T 
     Output Z  F T F T F

2 个答案:

答案 0 :(得分:1)

我不认为第二个适用于MCDC。您没有说明输入A独立地影响输出。在测试用例1中,A是T,输出Z是F.在测试用例4A中,A是F,输入D也变化。所以你不知道哪一个将输出改为T。

答案 1 :(得分:1)

Neither of your examples satisfies MC/DC.

To evaluate whether test cases satisfy MC/DC, a good approach is to pair up test cases, so that each pair:

  • Differs only in one value
  • Gives different results

There should be one such pair for every condition. So, for the first example:

  • case 1 and case 3 toggles A, but does not produce a different result
  • case 1 and case 2 toggles B, producing a different result
  • case 3 and case 5 toggles C, producing a different result
  • case 3 and case 4 toggles D, producing a different result

In the second example, the only pair that changes a single input value is cases 1 and 2. All other pairs change two or more values.

A test set that does provide full MC/DC in this case is:

test case No 1 2 3 4 5
Input A      T T F F F
Input B      T F F F F
Input C      F F F T F
Input D      F F F F T
Output Z     F T F T T
  • A is satisfied by 2 and 3
  • B is satisfied by 1 and 2
  • C is satisfied by 3 and 4
  • D is satisfied by 3 and 5