【发布时间】:2014-08-08 20:35:29
【问题描述】:
在下面的代码中,我介绍了 if 语句的两个分支之一。但我也想测试另一个分支,即当this.tom != null。
public void setTom(boolean cmsConsent, boolean ebConsent) {
if(this.tom== null){
this.tom= new Tom(cmsConsent,ebConsent);
}
}
如何写assert语句,覆盖所有分支?
【问题讨论】:
-
正如我所说,我已经测试了那个分支@MarkoTopolnik 所以下次我排除这个分支:)
-
看看你对该分支的测试是什么样子会很有帮助。
标签: java junit mockito testcase