logo Mojo's Maven plugin for Cobertura

This is the Mojo's Maven plugin for Cobertura. Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage.

homepage: mojo.codehaus.org/cobertura-maven-plugin
fresh index:
last release: 7 years ago, first release: 2 decades ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
cobertura:check (phase: verify)

Check the coverage percentages for unit tests from the last instrumentation, and optionally fail the build if the targets are not met. To fail the build you need to set configuration/check/haltOnFailure=true in the plugin's configuration.

cobertura:check-integration-test (phase: verify)

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. To fail the build you need to set configuration/check/haltOnFailure=true in the plugin's configuration.

cobertura:clean (phase: clean)

Clean up the files that Cobertura Maven Plugin has created during instrumentation.

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.

cobertura:dump-datafile

Output the contents of Cobertura's data file to the command line.

cobertura:help

Display help information on cobertura-maven-plugin. Call mvn cobertura:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

cobertura:instrument

Instrument the compiled classes.

Often used code snippets:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <formats>
      <format>html</format>
      <format>xml</format>
    </formats>
    <check/>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <formats>
      <format>html</format>
      <format>xml</format>
    </formats>
    <check>
      <branchRate>80</branchRate>
      <lineRate>90</lineRate>
      <haltOnFailure>false</haltOnFailure>
      <totalBranchRate>80</totalBranchRate>
      <totalLineRate>90</totalLineRate>
      <packageLineRate>90</packageLineRate>
      <packageBranchRate>80</packageBranchRate>
    </check>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>${cobertura.version}</version>
  <configuration>
    <check/>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>clean</goal>
        <goal>check</goal>
      </goals>
    </execution>
  </executions>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <format>xml</format>
    <maxmem>256m</maxmem>
    <aggregate>true</aggregate>
  </configuration>
</plugin>
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.7</version>
  <configuration>
    <instrumentation>
      <ignoreTrivial>true</ignoreTrivial>
    </instrumentation>
    <formats>
      <format>html</format>
      <format>xml</format>
    </formats>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.