Maven Cobertura Plugin Version 2.1 and the 100% Line and Branch Coverage Problem

May 12th, 2007 Mario Hochreiter

Maven's Cobertura plugin in version 2.1 introduced a very annoying bug which makes the plugin useless. The generated HTML report always shows 100% line and branch coverage. The most recommended way to avoid this problem is to use version 2.0 of the plugin (see Maven Users mailing list). But that's not a solution for me as the maven plugin version 2.0 still uses cobertura 1.7 for report generation which lacks some nice features of the cobertura version 1.8 which is used by the maven plugin version 2.1.

If you have a look at the issue tracking page, there is already a solution for the bug report. It's not directly a bug of the maven plugin but more a bug of cobertura itself if you have a look on following issue. The fix is already in the source code repository and will be part of the 1.9 release of cobertura. If you can't wait until cobertura 1.9 is realeased. I prepared a cobertura artifact which is compiled from the sources of the subversion repository and works with the maven plugin version 2.1.
All you have to do is to download the patched Cobertura files unzip them in a folder. In the folder issue the following command:

XML:
  1. mvn install:install-file -Dfile=cobertura-1.8.jar -DpomFile=cobertura-1.8.pom

to install them in the local repository. If you would like to install them in a remote repository:

XML:
  1. mvn depoloy:deploy-file -Dfile=cobertura-1.8.jar -DpomFile=cobertura-1.8.pom
  2. -DrepositoryId=<id-of-server-section-of-settings.xml> -Durl=<url-of-the-repositor-to-deploy>

Don't forget to change the version for the maven cobertura plugin to 2.1 in your pom! Then you will get such nice looking html reports about the code coverage for your project.

Entry Filed under: Maven

3 Comments Add your own

  • 1. bobs  |  May 22nd, 2007 at 4:29 pm

    I like your fix! Do you also have a Java 5 compiled version of the jar?

  • 2. Mario Hochreiter  |  May 22nd, 2007 at 5:11 pm

    No i don’t but at the issue tracking page there is a post (from Dirk Olmes) where a java 1.4 compiled version can be downloaded: http://jira.codehaus.org/browse/MCOBERTURA-61

    hope that help’s.

  • 3. bobs  |  May 22nd, 2007 at 7:13 pm

    That did help, thanks very much.

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

May 2007
M T W T F S S
« Apr   Oct »
 123456
78910111213
14151617181920
21222324252627
28293031  

Most Recent Posts