How to generate Cobertura Code Coverage Report using Maven from Hudson

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 02:02:31

问题


In my project I need to create Cobertura Code Coverage report from Hudson using maven build.
In Hudson I have added the Cobertura Code Coverage plugin.
I need the complete modification steps of pom.xml.


回答1:


Did you try to add this to your pom.xml in the reporting section?

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

Complete configuration steps can be found here.




回答2:


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



回答3:


To run Cobertura during package phase, do

 <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>         

Heres an example of pom

http://macgyverdev.blogspot.com/2011/04/development-environment-for-google-app.html

And here how to integrate in Hudson http://macgyverdev.blogspot.com/2011/04/hudson-continous-integration-for-google.html




回答4:


Cobertura doesn't actually seem to work with 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.



来源:https://stackoverflow.com/questions/2006014/how-to-generate-cobertura-code-coverage-report-using-maven-from-hudson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!