Let's integrate JaCoCo into our existing project:
- First, include the plugin that includes JaCoCo in the POM file:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.9</version> </plugin>
The second and third step is to include pre-executions and post-executions into the preceding plugin.
- The pre-execution prepares the agent to be configured and added to the command line.
- The post-execution ensures that the reports get created in the output folders:
<executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> <propertyName>surefireArgLine</propertyName> ...