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:

        <!-- Per-class thresholds -->
        <!-- Project-wide thresholds -->
          <!-- The "verify" phase occurs just before "install" -->

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).

+1  A: 

Add the following to the <check/> configuration.

Thanks for answering, but I tried that and it didn't work. From what I've read about that setting, it determines whether the build halts upon a test failure, not whether the build fails (or halts) because of low coverage. Is it working for you, or were you just suggesting something to try?
Andrew Swan

can we use cobertura without writing test cases???

You might be able to create Cobertura instrumented application. Then execute that application, and run your manual tests. The you should be able to create coverage reports.
Juha Syrjälä
+3  A: 
Pascal Thivent
I replicated your success using your config, so now I just have to integrate it into my real projects. BTW, there are several differences between my config and yours, e.g. my "executions" tag is a child of my "configuration" tag, whereas yours is a sibling (as in the book; I don't know why I deviated from that).
Andrew Swan
Glad to know. And indeed, configuration are different which is actually a good thing :) I don't know how I missed that.
Pascal Thivent