Re: Code coverage with pax-Exam

384 views
Skip to first unread message

Christoph Läubrich

unread,
Feb 26, 2013, 6:34:45 AM2/26/13
to op...@googlegroups.com
At the momment you have to enhance your artifacts (for cobertura) and the use these for the test case. It would be possible to use the new WeavingHook for this, I'm currently experiemnting with this but it is not included yet.

Am 22.02.2013 17:36, schrieb Charlie Mordant:
Hi,

I tried to integrate pax-Exam with Jacoco or Cobertura-it (in Maven) and never succeded.

Have you got an idea of how to do?


Best regards, Charlie


Harald Wellmann

unread,
Feb 26, 2013, 6:49:13 AM2/26/13
to op...@googlegroups.com
I've never tried using any coverage tools with OSGi, maybe this helps:
http://stackoverflow.com/questions/8737838/osgi-integration-testing-and-code-coverage

At any rate, I'd recommend JaCoCo and not Cobertura. When I added
Cobertura to a Spring web app, not only did it not produce coverage
output, but it made my tests fail.

Best regards,
Harald

2013/2/26 Christoph Läubrich <lae...@googlemail.com>:
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - op...@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Christoph Läubrich

unread,
Jul 26, 2013, 9:30:36 AM7/26/13
to op...@googlegroups.com, cmor...@gmail.com
I have recently experiemented with the weaving hook and cobertura and it theoretically works, they just introduced a bug with that in the latest version to fix another on in the previous...

To summarize: I have now evaluated JaCoCo (http://www.eclemma.org/jacoco/) and it just works like a charm out-of-the box with pax exam I use the following Option to archive code coverage with pax exam in a forked vm, for the native container it might be enough to use the ant/maven task as-is:

  String destFile = System.getProperty("itest.jacoco.destfile");
  String libFile = System.getProperty("itest.jacoco.libfile");
  VMOption jacoco = CoreOptions.vmOption("-javaagent:" + libFile + "=destfile=" + destFile);

Beside this, the Hudson/Jenkins integration for JaCoCo is mutch better than the cobertura one...

Harald Wellmann

unread,
Jul 26, 2013, 11:02:22 AM7/26/13
to OPS4J Mailing Lists
Good to know - thanks for sharing this!

Cheers,
Harald

2013/7/26 Christoph Läubrich <lae...@googlemail.com>:

Chetan Mehrotra

unread,
Jul 29, 2013, 4:02:09 AM7/29/13
to op...@googlegroups.com
Hi Christoph,

For usage with Maven with Forked container you can also use the Maven
plugin to prepare the command for you using the 'prepare-agent' goal
which would set the required vmOption value in a system property
taking care of locating the agent jar from maven repo. Have a look at
[1] and [2] for such usage

1. Use the prepare-agent goal to get a property populated
2. Configure the maven-failsafe-plugin to propagate the property to testcases
3. Read the property and pass it as a vmOption
CoreOptions.vmOption(System.getProperty("coverage.command"))

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>coverage.command</propertyName>
...
</configuration>
</execution>
<execution>
<id>report</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
...
</executions>
</plugin>

[1] https://github.com/apache/felix/blob/trunk/jaas/pom.xml#L309
[2] https://github.com/apache/felix/blob/trunk/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java#L111

Chetan Mehrotra
Reply all
Reply to author
Forward
0 new messages