O'Reilly logo

Apache Maven Cookbook by Raghuram Bharathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating code coverage reports for a site

Let us now include code coverage from the unit tests of our project in the site documentation.

How to do it...

Use the following steps to generate code coverage reports for a site:

  1. Open the Maven project for which you want to do this (for instance, project-with-documentation).
  2. Add the following code in the <build> section of the pom.xml file:
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.7.2.201409121644</version>
          <executions>
              <execution>
              <id>default-prepare-agent</id>
              <goals>
                  <goal>prepare-agent</goal>
              </goals>
              </execution>
          </executions>
        </plugin>
  3. Add the following code in the reporting section of the pom.xml file:
    <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required