Interfaces with default methods are not present in the report on Jenkins

742 views
Skip to first unread message

ra...@cotescu.com

unread,
Jun 23, 2017, 5:23:26 AM6/23/17
to JaCoCo and EclEmma Users
Hello Jacoco users and devs,

I have a relatively weird problem on my hands and after one day of doing everything that I could have thought of I still haven't found a solution.

In our project we have a set of public interfaces with default methods. The default behaviour is that they throw UnsupportedOperationException, allowing the implementations to decide which API level they want to support.

Since I wanted the team to use the same pattern for these interfaces, I've also added a unit test that checks that all the interfaces from the public API packages respect this pattern, by making sure we only expose default methods and that when invoked (using reflection) they throw UOE.

Running the build locally on Mac OS X (Java 1.8.0_112, HotSpot), Windows (1.8.0_121) and Linux (OpenJDK 1.8.0_131) everything works perfectly:

1. JaCoCo runs offline instrumentation (because we also have to use Powermock for some of the tests)
2. we run the tests
3. JaCoCo restores the classes
4. we generate the coverage report
5. we run the check (every class has to be at least 80% covered, same applies for the project)

When we try to run the same thing on Jenkins the check fails, since the interfaces I told you about are not analysed at all.

Jenkins runs Java 1.8.0_121, also HotSpot. Comparing a local session with the one from Jenkins clearly shows that the interfaces are missing altogether from the analysis on Jenkins. Running the build in debug mode (mvn -X) didn't show anything revealing. There's no JaCoCo plugin installed on Jenkins that could clash with the project's setup.

Any advice about what should I check more?

For reference, this is the JaCoCo config (both the plugin and the agent have the same version - currently 0.7.6, but I've had the same results with 0.7.9):

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>check-coverage</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<haltOnFailure>true</haltOnFailure>
<dataFile>${project.build.directory}/coverage.exec</dataFile>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
<excludes>
<!-- private enum; cannot test valueOf / values -->
<exclude>**/SocialMediaHelperImpl$WebsiteMetadata$Type.class</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/coverage.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>

And we also use the agent:

<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>

Thanks,
Radu

Marc R. Hoffmann

unread,
Jun 23, 2017, 10:49:10 AM6/23/17
to jac...@googlegroups.com
Hi Radu,

please let me ask some questions to make sure I fully understand your setup:

1) By "running on Jenkins" you mean executing your Maven build within
jenkins, right?
2) You're not using the JaCoCo Jenkins plugin at all, right?
3) The interfaces with default methods do show in the coverage report
but the default methods are not marked as executed (red), right?
4) The interfaces are not listed on the "Sessions" page of the JaCoCo
HTML report, right?

Cheers,
-marc

Radu Cotescu

unread,
Jun 23, 2017, 11:05:23 AM6/23/17
to jac...@googlegroups.com
Hi Marc,

1. yes
2. correct
3. correct
4. correct

Thanks,
Radu

--
You received this message because you are subscribed to a topic in the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jacoco/jX_g_0r-sZE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/d298e8a7-6bd9-7659-26ad-b90d97767cf7%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.

Marc Hoffmann

unread,
Jul 4, 2017, 10:23:14 AM7/4/17
to jac...@googlegroups.com

Hi Radu,

sorry for the silence, but currently I have no idea what could be wrong here. All I can do is to give you some random hints:

  • Actually we had a change in version 0.7.7: Classes with empty probes only are not written any more to the exec files. So in case the interfaces gets instrumented but not executed (or execution was not properly recorded for whatever reason) classes do not show up on the sessions page. Please run your tests with our latest release 0.7.9 only.
  • We changed instrumentation strategy for interfaces in 0.7.8. As above please only use release 0.7.9 in both environments.
  • Please check system.our/err of your test executions to see whether the JaCoCo runtime reports any problems.
  • Double check that the instrumented version of such a interface is used. You might send us such a class file, so we can double-check it is actually properly instrumented

Cheers,
-marc

You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAFkwx-c0i%3Dq6U%3DnQ1d7X4nhcLQvWnDg1TJ_mN5YyJ5_udRSk9Q%40mail.gmail.com.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages