I'm trying to get coverage report when running my webapp on Jetty, using cobertura. We already have cobertura running for unit-tests by using the surefire plugin. We also have the failsafe plugin configured for running our integration-tests.
I've already (manually) instrumented my war and deployed it.
When running mvn verify
with integration-tests only profile, it seems cobertura is working because I get all kind of new warnings in eclipse console (i'm running jetty from there) probably because byte-code was changed by cobertura.
But I don't get the .ser
file to be written, even when calling "stop"
on the jetty server.
I do get a .ser
file when running mvn cobertura:cobertura
and a report is generated under target/site
directory of my webapp. The report shows 0% coverage because cobertura:cobertura
doesn't run any tests.
How can I run my integration-tests using the failsafe make cobertura to work? Any other suggestions?
Thanks, Ben
I solved this issue by using cobertura-it plugin. It extends the original cobertura plugin and allows to use report-only goal. In addition, I must run two separate commands (see below) to test and generate reports (merging to 1 command does not work). Here is my plugin configuration.
So I run this:
mvn clean verify
Note that after Jetty is stopped, there is some cobertura messages:
Finally, I use
mvn site
to generate reports. Here is my report configurationPerhaps you need some
<execution>
tag to yourcobertura-maven-plugin
plugin config. There are some examples on http://mojo.codehaus.org/cobertura-maven-plugin/instrumentingDeploymentArtifact.html but this answer looks better: What is the proper way to use Cobertura with Maven 3.0.2