jenkins the definitive guide

(Jeff_L) #1
</formats>
</configuration>
</plugin>
...
</plugins>
<build>
...
</project>

This will generate code coverage metrics when you invoke the Cobertura plugin directly:


$ mvn cobertura:cobertura

The code coverage data will be generated in the target/site/cobertura directory, in a file called
coverage.xml.


This approach, however, will instrument your classes and produce code coverage data for every build,
which is inefficient. A better approach is to place this configuration in a special profile, as shown here:


<project>
...
<profiles>
<profile>
<id>metrics</id>
<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>
</profile>
...
</profiles>
</project>

In this case, you would invoke the Cobertura plugin using the metrics profile to generate the code
coverage data:


$ mvn cobertura:cobertura -Pmetrics

Another approach is to include code coverage reporting in your Maven reports. This approach is
considerably slower and more memory-hungry than just generating the coverage data, but it can make

Free download pdf