Social Media

Jacoco – Code Coverage

Jacoco is a free code coverage library for Java. It provides coverage(Counters) for –

  • Instructions
  • Branches
  • Cyclomatic Complexity
  • Lines
  • Methods

POM Configuration –

[sourcecode language=”xml”]




This can then be called by Jenkins using –

mvn clean test sonar:sonar

The above configuration excludes files ending in Util. Theres great debate over whether excluding fields is valid, but I think it is. Ideally I’d be able to exclude code that I consider ‘noise’, and there are plans to add support for this. I particularly like the idea of FilteringOptions, and like idea of excluding the following –

  • Private, empty default constructors – assuming no calls to it
  • Plain getters and setters

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: