我遇到了一个问题,即 cobertura 报告未涵盖所有测试用例,并且我在互联网上找不到令人满意的答案。
我有一个主要课程:
public class SomeClass {
public Somereturn method1(){
//Something doing here
}
public Somereturn method2(){
//Something doing here
}
public Somereturn method3(){
//Something doing here
}
public Somereturn method4(){
//Something doing here
}
}
当我为第一种或第二种方法准备测试用例时,cobertura 将确定其覆盖范围:
public testclass {
@Test
Public void test1mehtod1(){
// testing mothod1 for some scenario
}
@Test
Public void test2mehtod1(){
// testing mothod1 again for some other scenario
}
@Test
Public void test1mehtod2(){
// testing mothod2 some other scenario
}
}
这是由 cobertura 确定的,可以说是 50% 的覆盖率。
但如果我选择最后一个或倒数第二个方法:
public testclass {
@Test
Public void test1mehtod3(){
// testing mothod3 for some scenario
}
@Test
Public void test1mehtod4(){
// testing mothod4 for some other scenario
}
}
它拒绝识别覆盖率,仅显示 0% 的覆盖率。
如果我谈论现实,对于一个控制器类,我已经涵盖了 100% 准备所有测试用例。但 cobertura 仅显示 22% 的覆盖率。我正在开发一个 sprintboot 应用程序。