22

在我的项目中,我需要使用 maven build 从 Hudson 创建 Cobertura 代码覆盖率报告。
在 Hudson,我添加了 Cobertura Code Coverage 插件。
我需要pom.xml的完整修改步骤。

4

4 回答 4

32

您是否尝试将其添加到您pom.xmlreporting部分?

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <configuration>
       <formats>
           <format>html</format>
           <format>xml</format>
       </formats>
    </configuration>
</plugin>

完整的配置步骤可以在这里找到。

于 2010-01-05T12:50:42.830 回答
23

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
于 2013-09-20T16:13:13.607 回答
8

要在打包阶段运行 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

于 2011-04-22T07:31:44.393 回答
1

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.

于 2012-01-30T22:15:30.890 回答