作者:爵士723 | 来源:互联网 | 2023-05-22 17:18
鉴于代码:
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是否有办法在条件级别进行覆盖?
1> yole..:
是.如果您正在使用IntelliJ IDEA覆盖运行器,则需要将其切换到跟踪模式.