My previous Maven 2 Cobertura Plugin article gives a workaround for the very buggy version 2.1 of the Cobertura Maven Plugin.
This bug is fixed on versions 2.2 or higher, and consequently, that workaround does not work anymore.
For those reading my previous article and having difficulties configuring the plugin, this is my actual configuration.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<systemPropertyVariables>
<net.sourceforge.cobertura.datafile>target/cobertura/cobertura.ser</net.sourceforge.cobertura.datafile>
</systemPropertyVariables>
<!-- for JDK6 Support -->
<argLine>-Dsun.lang.ClassLoader.allowArraySyntax=true</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<check>
<haltOnFailure>false</haltOnFailure>
<regexes>
<regex>
<pattern>com.samaxes.business.*</pattern>
<branchRate>80</branchRate>
<lineRate>80</lineRate>
</regex>
<regex>
<pattern>com.samaxes.persistence.*</pattern>
<branchRate>80</branchRate>
<lineRate>80</lineRate>
</regex>
</regexes>
</check>
<instrumentation>
<includes>
<include>com/samaxes/business/**/*.class</include>
<include>com/samaxes/persistence/**/*.class</include>
</includes>
</instrumentation>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.5</version>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
I’m using the same kind of configuration but I can’t figure out why surefire does not read cobertura.ser (so the tests are launched twice: once for cobertura and once for surefire).
Did it happen to anybody here?
I do not think that your issue is related to the cobertura.ser file.
It may be due to this bug in Cobertura: http://jira.codehaus.org/browse/MCOBERTURA-83.
Thanks! I’ll check that.