Cobertura Maven Plugin

This plugin provides the features of Cobertura within the Maven 2 & 3 environment.

The report generated by this plugin is the result of executing the Cobertura tool against your compiled classes to help you determine how well the unit testing and integration testing efforts have been, and can then be used to identify which parts of your Java program are lacking test coverage.

This plugin uses Cobertura version 2.1.1 and requires Java 1.6.

Goals Overview

  • cobertura:check Check the coverage percentages for unit tests from the last instrumentation, and optionally fail the build if the targets are not met.
  • cobertura:check-integration-test Check the coverage percentages for unit tests and integration tests from the last instrumentation, and optionally fail the build if the targets are not met.
  • cobertura:clean Clean up the files that Cobertura Maven Plugin has created during instrumentation.
  • cobertura:dump-datafile Output the contents of Cobertura's data file to the command line.
  • cobertura:instrument Instrument the compiled classes.
  • cobertura:cobertura Instrument the compiled classes, run the unit tests and generate a Cobertura report.
  • cobertura:cobertura-integration-test Instrument the compiled classes, run the unit tests and integration tests and generate a Cobertura report.

Usage

General instructions on how to use the Cobertura Maven Plugin can be found on the usage page.

In case you still have questions regarding the plugin's usage, please feel free to contact the user mailing list. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the mail archive.

If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our issue tracker. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are most welcome too. Contributors can check out the project from our source repository and will find supplementary information in the guide to helping with Maven.

Examples

To provide you with better understanding of some usages of the Cobertura Maven Plugin, you can take a look into the following example: