在我的项目中,我需要使用 maven build 从 Hudson 创建 Cobertura 代码覆盖率报告。
在 Hudson,我添加了 Cobertura Code Coverage 插件。
我需要pom.xml的完整修改步骤。
4 回答
您是否尝试将其添加到您pom.xml
的reporting
部分?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
完整的配置步骤可以在这里找到。
Hudson needs a you to generate the coverage.xml
file. To do this without changing your pom.xml
, you can use:
mvn cobertura:cobertura -Dcobertura.report.format=xml
要在打包阶段运行 Cobertura,请执行
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<formats>
<format>xml</format>
</formats>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
这是一个pom的例子
http://macgyverdev.blogspot.com/2011/04/development-environment-for-google-app.html
在这里如何集成到 Hudson http://macgyverdev.blogspot.com/2011/04/hudson-continous-integration-for-google.html
Cobertura 似乎并没有与 hudson 合作。
I have a project where executing the command line: mvn clean package
Builds a coverage report generates an accurate coverage report with an average coverage of about 78% line and 74% branch.
Running the same goals on a Hudson server results in a coverage report showing 0% 0%.
Unfortunately the Jira site for the plugin doesn't seem to allow anyone to post issues so this issue is as yet unreported to the team.