给定代码:
public void foo(int age,boolean smart) {
if (age>18 && smart) { // <--- This is the part that should be covered
doSomething()
}
}
使用JUnit我测试foo(15,true)和foo(25,true)
IntelliJ将报告条件行已完全覆盖(绿色),但它是而不是。
在使用Jacoco的Eclipse中,该行正确地标记为部分覆盖,并且条件被染成黄色。
IntelliJ是否可以在条件级别提供覆盖?
最佳答案
是的。如果您使用的是IntelliJ IDEA CoverageRunner,则需要将其切换为跟踪模式。
关于unit-testing - 查看intellij中的条件覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28427194/