有没有人成功使用带有 cobertura maven 插件的 JUnit 的封闭式跑步者?我查看了插件文档并进行了一些搜索,但我无法确定如何配置插件以识别静态嵌套类中的测试
我有一个定义类似的测试类
@RunWith(Enclosed.class)
public class SomeTestClass {
public static class Testing {
@Test
public void testMethod() {
}
}
}
从 Eclipse 和 mvn test 运行 JUnit(我使用 surefire maven 插件)都可以毫无问题地运行我的所有测试,但是 cobertura maven 插件似乎无法识别它们,并且报告中的代码覆盖率为 0。我的 Cobertura maven 插件配置是
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<id>instrument</id>
<phase>site</phase>
<goals>
<goal>instrument</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
<configuration>
<check>
<branchRate>85</branchRate>
<lineRate>85</lineRate>
<haltOnFailure>false</haltOnFailure>
<totalBranchRate>85</totalBranchRate>
<totalLineRate>85</totalLineRate>
<packageLineRate>85</packageLineRate>
<packageBranchRate>85</packageBranchRate>
</check>
<encoding>UTF-8</encoding>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>