I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book Java Power Tools, but with no success. Here's the relevant snippet of my project's Maven 2 POM:
<build>
...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<check>
<!-- Per-class thresholds -->
<lineRate>80</lineRate>
<branchRate>80</branchRate>
<!-- Project-wide thresholds -->
<totalLineRate>90</totalLineRate>
<totalBranchRate>90</totalBranchRate>
</check>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>coverage-tests</id>
<!-- The "verify" phase occurs just before "install" -->
<phase>verify</phase>
<goals>
<goal>clean</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
<instrumentation>
<excludes>
<exclude>au/**/*Constants.*</exclude>
</excludes>
<ignores>
<ignore>au/**/*Constants.*</ignore>
</ignores>
</instrumentation>
</configuration>
</plugin>
...
</plugins>
...
</build>
As I say, the coverage report works fine, the problem is that the "install" goal isn't failing as it should if the line or branch coverage is below my specified thresholds. Does anyone have this working, and if so, what does your POM look like and which version of Cobertura and Maven are you using? I'm using Maven 2.0.9 and Cobertura 2.2.
I've tried Googling and reading the Cobertura docs, but no luck (the latter are sparse to say the least).