覆盖标准,独立条件到底是什么?
Coverage Criteria, What are independent conditions exactly?
谈到 MCDC(修改后的 Condition/Decision 标准)等覆盖标准时...
据说"Every point of entry and exit in the program has been invoked at least once, every condition in a decision in the program has taken all possible outcomes at least once, and each condition has been shown to affect that decision outcome independently. A condition is shown to affect a decision's outcome independently by varying just that condition while holding fixed all other possible conditions. [...]"
- https://en.wikipedia.org/wiki/Modified_condition/decision_coverage
这个描述对于什么构成独立标准相当模糊...那么,它们是什么?示例对任何语言都有帮助(C-family/python/haskell 首选)。
维基百科的定义是一种非正式的说法,MDCD更准确的定义是:
对于每个条件 c
,在每个决定 d
中,都有一个测试使得:
- 有一个测试
c == true
- 有一个测试
c == false
- 如果
c == true
时d
的结果是x
,那么c == false
时d的结果一定是!x
。
d
中的所有其他条件在两个测试用例中的评估相同。
如果可以创建满足这些条件的测试集,那么这表明每个条件都不是多余的:每个条件至少在某些情况下会影响程序的控制(因为有一个测试用例证明这个)。这就是"independently influences the outcome"的意思。
谈到 MCDC(修改后的 Condition/Decision 标准)等覆盖标准时...
据说"Every point of entry and exit in the program has been invoked at least once, every condition in a decision in the program has taken all possible outcomes at least once, and each condition has been shown to affect that decision outcome independently. A condition is shown to affect a decision's outcome independently by varying just that condition while holding fixed all other possible conditions. [...]" - https://en.wikipedia.org/wiki/Modified_condition/decision_coverage
这个描述对于什么构成独立标准相当模糊...那么,它们是什么?示例对任何语言都有帮助(C-family/python/haskell 首选)。
维基百科的定义是一种非正式的说法,MDCD更准确的定义是:
对于每个条件 c
,在每个决定 d
中,都有一个测试使得:
- 有一个测试
c == true
- 有一个测试
c == false
- 如果
c == true
时d
的结果是x
,那么c == false
时d的结果一定是!x
。 d
中的所有其他条件在两个测试用例中的评估相同。
如果可以创建满足这些条件的测试集,那么这表明每个条件都不是多余的:每个条件至少在某些情况下会影响程序的控制(因为有一个测试用例证明这个)。这就是"independently influences the outcome"的意思。