else if condition 运行 如果第一个 if 条件在分支覆盖测试中为真?
Does else if condition run if the the first if condition was true in branch coverage testing?
给定以下场景:
If (condition1)
statement..
Else if (condition2)
statement..
Else if (condition3)
statement..
else end
我的问题是 --> 在线路/分支覆盖测试中,如果第一个条件为真,第二个条件是否可能 运行?
注:if --> else if not if --> if
谢谢:)
执行有四种可能(我为最后一个else
案例添加了一条语句):
| 1 | 2 | 3 | 4 |
If (condition1) | * | * | * | * |
statement.. | * | | | |
Else if (condition2) | | * | * | * |
statement.. | | * | | |
Else if (condition3) | | | * | * |
statement.. | | | * | |
else | | | | * |
statement... | | | | * |
end if | * | * | * | * |
星号表示 4 种情景中的每一种 statements/conditions 是 executed/evaluated。
一旦其中一个缩进语句被执行,就不会在该构造中评估其他条件或语句。
在具有分支覆盖的测试中,测试包括几个不同的状态,因此条件(希望如此)有时为假,有时为真,这样每个分支至少在一个测试中被执行。如果是这种情况,那么您有 分支覆盖率 。
但这并不意味着在 这些测试中有一个 违反了上述模式。同样在这些测试运行中,如果一个 if
条件 returns 为真,则其余条件保持未评估状态。
给定以下场景:
If (condition1)
statement..
Else if (condition2)
statement..
Else if (condition3)
statement..
else end
我的问题是 --> 在线路/分支覆盖测试中,如果第一个条件为真,第二个条件是否可能 运行?
注:if --> else if not if --> if
谢谢:)
执行有四种可能(我为最后一个else
案例添加了一条语句):
| 1 | 2 | 3 | 4 |
If (condition1) | * | * | * | * |
statement.. | * | | | |
Else if (condition2) | | * | * | * |
statement.. | | * | | |
Else if (condition3) | | | * | * |
statement.. | | | * | |
else | | | | * |
statement... | | | | * |
end if | * | * | * | * |
星号表示 4 种情景中的每一种 statements/conditions 是 executed/evaluated。
一旦其中一个缩进语句被执行,就不会在该构造中评估其他条件或语句。
在具有分支覆盖的测试中,测试包括几个不同的状态,因此条件(希望如此)有时为假,有时为真,这样每个分支至少在一个测试中被执行。如果是这种情况,那么您有 分支覆盖率 。
但这并不意味着在 这些测试中有一个 违反了上述模式。同样在这些测试运行中,如果一个 if
条件 returns 为真,则其余条件保持未评估状态。