Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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