我们有一个多项目,我们正在尝试运行 Cobertura 测试覆盖率报告,作为我们 mvn 站点构建的一部分。我可以让 Cobertura 在子项目上运行,但它错误地报告 0% 的覆盖率,即使报告仍然突出显示单元测试命中的代码行。
我们正在使用 mvn 2.0.8。我试过跑步mvn clean site
,mvn clean site:stage
和mvn clean package site
。我知道测试正在运行,它们出现在万无一失的报告中(txt/xml 和站点报告)。我在配置中遗漏了什么吗?Cobertura 是否不适用于多项目?
这是在父 .pom 中:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>clean</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<inherited>true</inherited>
</plugin>
</plugins>
</reporting>
我尝试在子 .poms 中使用和不使用以下内容运行它:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
</reporting>
我在构建的输出中得到了这个:
...
[INFO] [cobertura:instrument]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Instrumenting 3 files to C:\workspaces\sandbox\CommonJsf\target\generated-classes\cobertura
Cobertura: Saved information on 3 classes.
Instrument time: 186ms
[INFO] Instrumentation was successful.
...
[INFO] Generating "Cobertura Test Coverage" report.
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 3 classes.
Report time: 481ms
[INFO] Cobertura Report generation was successful.
报告如下所示: