Issue Details (XML | Word | Printable)

Key: MCOBERTURA-86
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Jean-Francois Poilpret
Votes: 24
Watchers: 17
Operations

If you were logged in you would be able to see more operations.
Maven 2.x Cobertura Plugin

no coverage reported for integration-test

Created: 01/Mar/08 09:39 AM   Updated: 18/Jun/09 01:36 AM
Component/s: None
Affects Version/s: 2.2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File CoberturaIntegrationReportMojo.patch (2 kB)
2. Text File CoberturaReportOnlyMojo.patch (1 kB)

Environment: Windows XP, maven 2.0.8


 Description  « Hide
In my project, I have both unit tests ("test" phase) and integration tests ("integration-test" phase).
So far I could manage configuring maven-surefire-plugin and maven-surefire-report-plugin to execute both tests correctly and also generate 2 different reports.
Then I have added cobertura-maven-plugin to the reporting in order to get coverage but unfortunately only unit tests have their coverage reported (I know it because I have some classes which are only integration tested but are reported as 0% covered).
After trying to find information on the mailing lists, on the web and other existing resources, I could not find any hint on how to make this work.
It looks like cobertura-maven-plugin, by its current design, will never run integration-test to collect coverage, it seems to stop at the "test" phase.

Thus whenever a POM project has integration tests and uses cobertura-maven-plugin for coverage report, the generated reports are wrong, which is very misleading.

Actually, I was surprised not to find this issue already in JIRA.

Is there a chance this gets fixed soon? Or is there a usable workaround for this problem (besides switching to clover which I am not sure it would work better ) Did someone succeed in patching cobertura-maven-plugin to get the correct behavior?



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Kalle Korhonen added a comment - 10/Mar/08 02:36 PM
The documentation for cobertura:cobertura flat out says that it runs the "test" phase prior to executing itself, so I assume this currently cannot be configured. There's of course much more complicated cases that people use the integration-test phase for, but for a lot of projects, it'd be enough if you could configure Cobertura to at least include or run integration-test phase instead. Email thread at http://www.mail-archive.com/users@maven.apache.org/msg78743.html.

Damien Lecan added a comment - 06/Mar/09 01:26 AM
Someone to work on this ?
Thanks

Stevo Slavic added a comment - 03/Apr/09 04:31 AM
Here's a patch, with new cobertura:cobertura-integration report mojo, which extends existing cobertura report mojo but instead of test phase executes verify phase to have pre-integration-test, integration-test, and post-integration-test phases to execute as well. To use it one should define in pom reporting section something like this:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3-SNAPSHOT</version>
<reportSets>
<reportSet>
<reports>
<report>cobertura-integration</report>
</reports>
</reportSet>
</reportSets>
</plugin>

This has been tested only on a trivial example project, and appears to be working well. I'm absolute beginner when it comes to mojo development, so this patch should be treated in that light, just as an suggestion on how this issue could be resolved.

The second patch adds one more new cobertura:report-only mojo, which executes only validate phase. Idea is that one should be able to use it together with cobertura:clean cobertura:instrument mojos, for fine-grained control over instrumentation process.


Stevo Slavic added a comment - 21/Apr/09 06:39 AM
I've tested and can confirm that both new Mojo's work well with relatively big multi-module projects.

Can someone else please try too?

Is it possible to get at least report-only mojo included in 2.3? With it, and with existing clean and instrument mojos, one can have more complete control over what and when gets instrumented, run tests and then get a coverage report only without rerunning of tests just for report. cobertura-integration mojo is not needed, but can be useful for simpler use cases, where with less configuration one can get coverage data for tests run in integration-test phase along with coverage data for tests in test phase.


Tom Vaughan added a comment - 05/Jun/09 01:24 PM
Hi,

How/where do I go to get the 2.3-SNAPSHOT release? I don't see it on ibiblio, but I'd love to get that version to help test this function.

Thanks,
Tom


Simon Brandhof added a comment - 06/Jun/09 03:50 AM
Snapshot is deployed but I'm not sure that this patch has been applied.

Stevo Slavic added a comment - 06/Jun/09 08:18 AM
To test the cobertura:report-only mojo patch one can check out latest cobertura-maven-plugin sources from http://svn.codehaus.org/mojo/ under trunk/mojo/cobertura-maven-plugin, apply the patch, install the plugin snapshot in to your local repository, and then use it from your maven project.

Fabrice Daugan added a comment - 18/Jun/09 01:36 AM
Hi Stevo,
I've patched the 2.3 snapshot with your work, and it works on big pom tree (parent/module) configuration.
But how did you solved the "classesDirectory " problem when using : surefire+selenium+cobertura when executing test, deployment, it and site into an unique maven execution ?
Removing the "readOnly" flag from the war plugin slove partially the problem, but i think there is a much simplier solution to run correctly cobertura ....
Can you attach a pom sample and the associated maven command line you use please?

Thanks