代码覆盖率 - 当 if 中的语句运行时,如何部分触及 if
Code Coverage - How can an if be partially touched when the statement in the if runs
我有以下代码
我的问题是,当 if 条件的真实部分运行时,如何才能部分覆盖 if
条件?这是一个短路 And &&
但双方都必须评估真正的触发条件。
因为您还没有测试导致它为假的条件,即未执行
例如当
(productBuildType.MasterId.HasValue) == false
或
(productBuildType.MasterId.Value > 0) == false
为了测试那些我会有一个测试用例
productBuildType.MasterId = null
还有另一个地方
productBuildType.MasterId = 0
我有以下代码
我的问题是,当 if 条件的真实部分运行时,如何才能部分覆盖 if
条件?这是一个短路 And &&
但双方都必须评估真正的触发条件。
因为您还没有测试导致它为假的条件,即未执行
例如当
(productBuildType.MasterId.HasValue) == false
或
(productBuildType.MasterId.Value > 0) == false
为了测试那些我会有一个测试用例
productBuildType.MasterId = null
还有另一个地方
productBuildType.MasterId = 0