注:机翻,未校。
What is MC/DC?
什么是 MC / DC?
Modified Condition/Decision Coverage (MC/DC) is a code coverage criterion commonly used in software testing. For example, DO-178C software development guidance in the aerospace industry requires MC/DC for the highest Design Assurance Level (DAL) or Item Development Assurance Level (IDAL).
修改的条件/决策覆盖率 (MC/DC) 是软件测试中常用的代码覆盖率标准。例如,航空航天业的 DO-178C 软件开发指南要求 MC/DC 达到最高设计保证级别 (DAL) 或项目开发保证级别 (IDAL)。
Code coverage is a way of measuring the effectiveness of your test cases. The higher the percentage of code that has been covered by testing, the less likely it is to contain bugs when compared to code that has a lower coverage score. There are three other types of code coverage that are worth considering in relation to MC/DC: Statement coverage, Decision coverage and Multiple condition coverage.
代码覆盖率是衡量测试用例有效性的一种方式。测试覆盖的代码百分比越高,与覆盖率分数较低的代码相比,它包含错误的可能性就越小。与 MC/DC 相关的其他三种类型的代码覆盖率值得考虑:语句覆盖率、决策覆盖率和多个条件覆盖率。
In addition to the criteria required by statement and decision coverage, MC/DC requires that ‘Each condition in a decision has been shown to independently affect that decision’s outcome’.
除了声明和决策覆盖率要求的标准外,MC/DC 还要求“已证明决策中的每个条件都独立影响该决策的结果”。
满足 MC/DC 要求的四个条件
Modified Condition/Decision Coverage (MC/DC) is a method used in software testing to test highly critical systems.
修改的条件/决策覆盖率 (MC/DC) 是软件测试中用于测试高度关键系统的一种方法。
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.
MC/DC 要求必须测试每个条件的所有可能状态,同时保持其他条件不变。此外,必须显示单个条件的变化以改变结果。
Below are the four conditions to fulfill the requirements of MC/DC:
以下是满足 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++:
请考虑以下 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:
在上面的代码片段中,我们有三个布尔变量(条件)。下面是真值表,其中显示了这些变量的所有可能值以及上述代码片段第 7 行中布尔表达式 (decision) 的结果:
Test No. | a | b | c | a && b || c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|