【发布时间】:2012-07-01 14:31:01
【问题描述】:
我正在尝试使用 cobertura 为我们的多模块 maven 项目生成代码覆盖率报告。在我运行 mvn clean 然后运行 mvn package 之后。然后,在我们运行 JUnit 测试的模块之一中,为该模块生成的覆盖率报告与预期的一样正确。但覆盖范围仅适用于少数包裹。并非所有包都包括在内。请记住,它是一个多模块项目,有一个父 POM,每个子模块都有自己的 POM。我是否还应该在每个子 POM 中包含 cobertura maven 插件详细信息?
但是,在其他 /target/site/cobertura 目录中生成的单个模块特定覆盖率报告对于线路覆盖率和分支覆盖率都报告为零。
在我的父 POM 中我是否遗漏了什么?我没有对 目录中的任何子 POM。请告诉我 如何为多模块 maven 项目生成代码覆盖率报告 使用 cobertura。
这是我的父 POM 的样子。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
<inherited>true</inherited>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
...
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<type>plugin</type>
<scope>package</scope>
</dependency>
</dependencies>
谢谢!
【问题讨论】:
-
您在 maven-compiler-plugin 配置部分中使用/指定了哪个 jdk 版本?
标签: cobertura