Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Jacoco is a Java code coverage tool which measures your code coverage, generates helpful HTML pages, can enforce minimum line and branch coverage in the build. It can be integrated with Jenkins so you can view all coverage metrics for your project.

Jacoco has been added to Synapse-Repository-Services, but it can be added to any Java Maven project.

Enabling Jacoco in Jenkins

To enable Jacoco in your devp* build in Jenkins, you’ll need to enable build artifacts in your project. Go to your project, click “Configure”, and scroll down to “Post-build Actions”. Add the “Archive the artifacts” action and set “Files to archive” to “**/*” (that is, everything). (Note the terminology. In this case “archive” means “save the artifacts so they’re available for me to look at after the build is done.)

This enables Jacoco for all your builds going forward.

To view your code coverage, go to one of your build instances, and click on “Build Artifacts”.

Jacoco is configured at the root of Synapse-Repository-Services, but executes on a per-project basis. To find your build artifacts, click through the folder directory to your project (example, “services”, then ”repository-managers”), then click “target”, the “site/jacoco”, then scroll down to “index.html”.

Running Jacoco in the command line

By default, running mvn installwill run everything, including Jacoco coverage checks. To open your coverage report, browse to target/site/jacoco/index.html. (On a Mac, you could just run open target/site/jacoco/index.html.)

If for whatever reason, you want to generate Jacoco coverage reports, but don’t want to run everything associated with install, you can run mvn test jacoco:report jacoco:check. (Note that in order to generate coverage reports, Jacoco still needs to execute the tests.)

  • No labels