Hi!

cobertura:cobertura executes it's own lifecycle: instruments the classes,
instrumented classes are saved to target/generated-classes/cobertura, and
executes unit tests. Instrumented classes dump coverage data to
target/conbertura/cobertura.ser. There are two things to understand:

1. When cobertura:cobertura is executed, dependencies are not instrumented.
You have to have enabled instrumentation, see cobertura:instrument goal.
This will produce jars with instrumented classes, so be careful not to
distribute them.
2. Each module will write coverage data to it's own
target/conbertura/cobertura.ser file. I think it's possible to configure
instrumentation so that all jars write to the same cobertura.ser file, but
I don't know whether it's normal, and I never tried that. When you have
multiple cobertura.ser files, you can merge them with ant script and
generate report from the merged file.

Check build-configurator project [1], it does what you need. I used
instructions from cobertura-maven-plugin to configure the build [2].

[1] https://github.com/htfv/build-configurator
[2]
http://mojo.codehaus.org/cobertura-maven-plugin/instrumentingDeploymentArtifact.html


Regards,
htfv (Aliaksei Lahachou)


On Sat, Jun 30, 2012 at 4:07 AM, <kfmoh...@uci.edu> wrote:

> Hi,
>
> I am trying to generate code coverage report for our multi-module maven
> project using cobertura. After I run mvn package, in one of the modules
> from where we run JUnit tests, the coverage report is correct as expected.
>
> However, coverage report generated in the other
> <module-name>/target/site/cobertura directories is reported as zero for
> both line and branch coverage.
>
> Am I missing something, in my parent POM, I have not made any changes to
> any of the child POMs in the <module-name> directories. Please let me know
> how to generate the code coverage report for a multi module maven project
> using cobertura.
>
> Here is how my parent POM looks like.
>
> <plugin>
>                             <groupId>org.codehaus.mojo</groupId>
>                             <artifactId>cobertura-maven-plugin</artifactId>
>                             <version>2.5.1</version>
>                              <configuration>
>                                 <formats>
>                                     <format>html</format>
>                                     <format>xml</format>
>                                 </formats>
>                              </configuration>
>                              <inherited>true</inherited>
>                              <executions>
>                                  <execution>
>                                      <phase>package</phase>
>                                          <goals>
>                                              <goal>cobertura</goal>
>                                          </goals>
>                                  </execution>
>                              </executions>
>                         </plugin>
>
> ...
> <dependencies>
>     <dependency>
>         <groupId>org.codehaus.mojo</groupId>
>         <artifactId>cobertura-maven-plugin</artifactId>
>         <version>2.5.1</version>
>         <type>plugin</type>
>         <scope>package</scope>
>     </dependency>
>     </dependencies>
>
> Thanks!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>

Reply via email to