JaCoCo report generation using maven

I captured the coverage details in the jacoco.exec file. Size 6Mb. I need to create a coverage report using maven. I tried below

<dependencies> <dependency> <groupId>org.jacoco</groupId> <artifactId>org.jacoco.ant</artifactId> <version>0.7.0.201403182114</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.6.3.201306030806</version> <executions> <!-- Ensures that the code coverage report for integration tests after integration tests have been run. --> <execution> <id>post-integration-test</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> <configuration> <!-- Sets the path to the file which contains the execution data. --> <dataFile>D:/JaCoCo/jacoco.exec</dataFile> <!-- Sets the output directory for the code coverage report. --> <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> 

It generates a zero percent coverage report.

Before testing, the jacoco.exec file was zero in bytes, and now it has a size of 6 MB. Is there something I don't see in pom.xml?

+6
source share
1 answer

Here is the jacoco plugin configuration.

  <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.5.10.201208310627</version> <configuration> <skip>${maven.test.skip}</skip> <output>file</output> <append>true</append> </configuration> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-site</id> <phase>verify</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> 
  • When maven:test starts, it will generate a jacoco.exec file
  • When running jacoco:report it creates a report in an html file in the target / site / jacoco directory. You can view the report by opening index.html
+10
source

All Articles