Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Cobertura plugin not generating coverage.xml

I am trying to generate a coverage.xml so that I can reference it in Cobertura plugin of Hudson, but the file is not being created.

I've added the following to my POM

 <reporting>     <plugins>         <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>         </plugin>     </plugins> </reporting> 

After running mvn cobertura:cobertura, the HTML site is generated as expected at **\target\site\cobertura, but coverage.xml is nowhere to be found. What am I missing/misunderstanding?

I am running Maven 3.0.3

like image 795
kjl Avatar asked Feb 22 '12 16:02

kjl


People also ask

How does cobertura generate code coverage reports?

1. Cobertura Code Coverage Report. Do nothing, just type the following Maven command to download and run the maven-cobertura-plugin automatically. Maven will generate the Cobertura code coverage report at ${project}/target/site/cobertura/index.

Which is the target location where cobertura coverage XML data will be generated?

Cobertura always uses default value target/site/coverage. xml path when running Sonar Scanner. Which Sonar property should be used to specify multiple cobertura coverage.


2 Answers

Add below lines to your application Goals:(configure section of the application in jenkins)

cobertura:cobertura -Dcobertura.report.format=xml 

pom.xml changes:

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

like image 183
Sreedhar GS Avatar answered Sep 26 '22 17:09

Sreedhar GS


I put the plugin in the build section and it works:

<build>     <plugins>         <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>         </plugin>     </plugins> </build> 

The reporting section and its differences to the plugin section are described here. I don't know if this is a maven [3.0.4] or cobertura-plugin issue.

like image 45
FrVaBe Avatar answered Sep 22 '22 17:09

FrVaBe