Coveralls is web service created by LEMUR Heavy that helps tracking code coverage over time. Coveralls is free to use for open source projects and it requires that the projects are hosted at GitHub. The service was originally created for Ruby projects, but the provided API allows anybody to create code coverage report clients. Numerous integrations have been created for different languages such as Python, PHP, Node.js and Scala by the open source community, but there was no support for Java projects. I find this odd, because in the enterprise Java world such metrics are everyday life. There are plenty of different coverage tools and metrics platforms available like Cobertura, JaCoCo, SonarQube (previously known as Sonar) and so on.

Coveralls integrates nicely with Travis CI, which is a continuous integration service for GitHub hosted projects. Travis CI is also free to use for open source projects. GitHub, Travis CI and Coveralls now provide a good continuous integration platform for open source projects. A lot of languages are already supported by these tools and GitLab is a nice example of a widely used open source project using the services. Java ecosystem is poorly supported even though it is backed by a large open source community.

I have created coveralls-maven-plugin that can be used to provide coverage reports to Coveralls web service. The plugin also integrates nicely with Travis CI, so that every build run by Travis CI will be reported to Coveralls. This means good tracking of code coverage over time for your projects. The coverage maven plugins can also be configured to fail builds for too low code coverage on unit tests.

Here’s some of the plugin highlights:

  • 1.1.0 version supports Cobertura and JaCoCo coverage Maven plugins.
  • Fully streaming implementation for fast report generation and small memory footprint. This is good for big projects that could consume the limited resources of Travis CI.
  • Contributing to the plugin is fairly easy. Code is clean and has simple interfaces to provide support for additional coverage tools and continuous integration services.
  • The plugin is easy to setup. Setting one configuration value is sufficient for most use cases.
  • The project is licensed under the MIT license.

Full documentation is available at GitHub and for reference jersey-mustache project is using the plugin with Travis CI and Coveralls integrations.

Posted in Java | Tagged , , ,
Share this post, let the world know

7 Comments

  1. Tapio Rautonen
    Posted 2013/07/02 at 23:01 | Permalink

    Version 1.2.0 of the coveralls-maven-plugin released with the following changes:
    + Coverage metrics recorded and logged in the execution of the goal
    + Build timestamp added and sent to Coveralls
    + Validation of the Job to fail fast on configuration issues

  2. Tapio Rautonen
    Posted 2013/07/30 at 11:05 | Permalink

    Version 2.0.0 of the coveralls-maven-plugin released with the following changes:
    + Built-in support for Travis, Circle, Codeship, Jenkins and Bamboo continuous integration services
    + Multi-module report aggregation with Cobertura
    + Support for multiple source directories
    + Dry run property for test builds

  3. Posted 2014/01/05 at 21:08 | Permalink

    Many thanks for writing this great Maven plugin for Coveralls. It worked for me with no problems. Bravo!

  4. feynman
    Posted 2014/03/05 at 01:54 | Permalink

    Hi there,

    I have a project with an ant based build system, which uses jacoco to generate coverage reports. I’ve been wondering about using your plugin to push them to coveralls. Obviously your plugin wouldnt work with ant without some serious effort, however it seems like I should be able to do the following in a travis script:
    1) Generate the jacoco xml report file in an ant script
    2) Submit the file to coveralls using a very minimal mvn script.
    Does this seem like it should be posible with your mvn plugin?

    Additionally I have a multi-project build, such that multiple jacoco xml reports are generated (for modules in the same repo), is there a way to chain these together with your plugin?

    Thanks

  5. Posted 2014/03/06 at 00:33 | Permalink

    Good job Tapio! Thank you for creating this great plugin. I just started using it on the Tr8n Java SDK. Took me about 5 minutes to get it all setup and running.

    I’ve also added a few lines of Ruby code and a shell script to create a source code monitor that builds code and generate reports every time I save files. On a mac it will also show a notification message for me once the build is complete.

    https://github.com/tr8n/tr8n_java_core/blob/master/script/test

  6. Tapio Rautonen
    Posted 2014/03/06 at 07:53 | Permalink

    @feynman I think the suggested approach is fully doable with the coveralls maven plugin. You can run the coveralls:jacoco goal independently and just configure the ‘coverallsFile’ property to point to the location of your ant built jacoco report file. The coveralls goal does not trigger any other maven lifecycle goals so it should not require the basic maven project structure or anything else.

    Currently my plugin does not support aggregation of reports from same coverage tool. I have a version 3 roadmap in my head and this is a feature that will most likely get in there when I get the time to implement. This way more tools that do not support multi module aggregation can be used with the plugin. Also the chaining of different coverage tools to a single aggregate report will be the default configuration approach in the later versions.

    If you have any issues, feel free to post to the github issues section of the project.

  7. Tapio Rautonen
    Posted 2014/03/06 at 07:58 | Permalink

    @michael Nice to hear! I tried to make the plugin as simple as it gets to adopt in projects build with Travis CI.

    The script you have is fine for small projects, but when the project gets bigger, it probably has thousands or tens of thousands of unit tests, it will proably kill totally your dev machine when the unit tests are triggered on file save. I personally run the relevant tests straight from IDE and let the CI do the rest.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">