使用EclEmma Eclipse代码覆盖插件运行此单元测试后,它返回100%的分支覆盖率,即覆盖4个分支中的4个,我预计只有2个这里覆盖的4个分支中有50%覆盖。 如果我证明是正确的,任何人都可以提出更好的分支机构覆盖工具。提前致谢。请确认/评论分支覆盖问题我看到EclEmma Eclipse Plugin
@Test
public void testTT(){;
assertTrue(bar(true, true)==3);
}
@Test
public void testFF(){;
assertTrue(bar(false, false)==8);
}
int bar(boolean cond1, boolean cond2) {
int answer = 1;
if (cond1) {
answer = answer * a();
} else {
answer = answer * b();
}
if (cond2) {
answer = answer * c();
} else {
answer = answer * d();
}
return answer;
}
private int a(){
return 1;
}
private int b(){
return 2;
}
private int c(){
return 3;
}
private int d(){
return 4;
}
感谢您的意见,看了一轮后,我发现JMockit:http://jmockit.org提供路径覆盖,似乎适用于我测试过的简单情况它与。我也看到了一些商业工具似乎提供了路径覆盖,https://www.parasoft.com和http://www.coverity.com/products/coverity-save/ – newlogic