Coverage always zero percent.

3,785 views
Skip to first unread message

jeffw...@gmail.com

unread,
Oct 1, 2013, 3:42:43 PM10/1/13
to jac...@googlegroups.com
I have a multi-module project that I am trying to get code coverage from. In my root pom i have set up an it profile like so:

{code}
<profile>
<id>it</id>
<modules>
<module>model</module>
<module>common</module>
<module>business</module>
<module>eis</module>
<module>web</module>
</modules>

<build>
<pluginManagement>
<plugins>
<!-- ignore unit tests for now -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
{code}

In my web module where I have all my integration tests currently, I have set things up like this:

{code}
<profile>
<id>it</id>
<build>
<testResources>
...
</testResources>
<plugins>
<!-- ignore unit tests for now -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.plugin.version}</version>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<includes>
<include>**/*IT*</include>
</includes>
<argLine>${jacoco.agent.argLine}</argLine>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
<propertyName>jacoco.agent.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo.plugin.version}</version>
<executions>
...
</executions>
<configuration>
...
<properties>
<cargo.servlet.port>9191</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
<!--<cargo.jvmargs>${jacoco.agent.argLine}</cargo.jvmargs>-->
</properties>
<deployables>
...
</deployables>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>
{code}

With the above settings, mvn completes successfully if I do a mvn clean verify -Pit, but when I look at my reports, I am getting zero percent coverage for the 188 integration tests that I have. If I uncomment the cargo.jvmargs, all my integration tests return 404 errors. What am I doing wrong?

Marc R. Hoffmann

unread,
Oct 2, 2013, 1:03:52 AM10/2/13
to jac...@googlegroups.com
Hi,

what do you see when you click on the "Sessions" link in the top right
corner of your HTML report? Are your classes under test listed?

Best regards,
-marc

jeffw...@gmail.com

unread,
Oct 2, 2013, 10:28:46 AM10/2/13
to jac...@googlegroups.com
Hey Marc,

Unfortunately they are not listed there. I assumed putting the argLine in the maven-failsafe-plugin would have used my IT tests for the code coverages. How do I make classes be used with the sessions???
Thank you for helping me!!!

Sharing the Love,
Jeff

Marc Hoffmann

unread,
Oct 2, 2013, 10:41:55 AM10/2/13
to jac...@googlegroups.com
Typical reasons for this are:

1) Wrong includes/excludes configuration (don't configure those at all
at the beginning)
2) JaCoCo agent attached to wrong JVM (e.g. in case of client/server IT
scenarios)

Best regards,
--marc

jeffw...@gmail.com

unread,
Oct 2, 2013, 11:29:31 AM10/2/13
to jac...@googlegroups.com
Thanks again for helping me, but I'm unsure on how to change my configuration to accomplish your suggestions.

So I put an includes with the package name like "com.company.*" in the jacoco-maven-plugin for the prepare-agent goal and now I'm seeing my test classes in the sessions tab, but I am still getting zero coverage in the coverage report. What else am I missing?

Many Thanks,
Jeff

Marc Hoffmann

unread,
Oct 3, 2013, 10:58:01 AM10/3/13
to jac...@googlegroups.com
Hi Jeff,

so your classes show up

a) on the sessions page and
b) in the coverage hierarchie with 0% coverage

Right? This means that the classes used at runtime are different classes
than the one at report generation time.

Cheers,
-mrc

jeffw...@gmail.com

unread,
Oct 8, 2013, 5:00:48 PM10/8/13
to jac...@googlegroups.com
Hey MRC,

So how would I make the classes used at runtime be the same classes that are used at report generation time?

Thank you so much for your time!!!

Sharing the Love,
Jeff

jeffw...@gmail.com

unread,
Oct 10, 2013, 1:51:27 PM10/10/13
to jac...@googlegroups.com, jeffw...@gmail.com
Hey MRC,

I posted a sample app that shows exactly what I am seeing. Is there any chance you can eyeball and let me know what I am doing wrong??? https://github.com/jeffwysong/coverage-multi-module

Thanks for your time.

Sharing the Love,
Jeff

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages