tomcat + jacoco agent does not report coverage correctly.

944 views
Skip to first unread message

Hyunil Shin

unread,
Jun 1, 2016, 12:57:36 AM6/1/16
to JaCoCo and EclEmma Users
Issue
- tomcat + jacoco agent does not report coverage correctly.
- exec file was generated, but when I checked, code which is tested is reported as unused.

When I ran mvn jetty:run (no configuration jacoco in pom.xml, MAVEN_OPTS) + jacoco agent, it reported correctly.

To compare two exec files above, the size is different.
Correct one is bigger.

any idea to handle this?

Marc R. Hoffmann

unread,
Jun 1, 2016, 1:08:52 AM6/1/16
to jac...@googlegroups.com
Configuring Tomcat can be tricky as it envolves more than one Java process: One to start and stop the server and the actual server. Make sure that the agent is configured for the actual server and not just for the controller.

In the JaCoCo report page there is a link "Sessions" on the top right corner which lists all classes seen by the agent at runtime. Can you please check whether your app classes are listed or is it just tomcat internals? In the latter case you probably attached the agent to the wrong process.

Regards,
-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/79355c1d-c586-47f5-8037-21b6b514604b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Hyunil Shin

unread,
Jun 1, 2016, 1:53:50 AM6/1/16
to JaCoCo and EclEmma Users
Where is Sessions?
I am looking at Jenkins Jacoco plugin.
What you mean is html report?

Marc R. Hoffmann

unread,
Jun 1, 2016, 2:01:32 AM6/1/16
to jac...@googlegroups.com
I was talking about the native JaCoCo report.

No ides about the debugging options of the Jenkins plugin, please ask
them (we're not maintaining this plugin here).

In case you're using Eclipse you can use the EclEmma plugin and open the
exec files directly to inspect the content. Alternatively here is a
small code snippet to dump the content:
http://eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java

Regards,
-marc
--
Marc Hoffmann
hoff...@mountainminds.com
_______________________________________________
Mountainminds GmbH & Co. KG

Nussbaumstr. 4 * 80336 Muenchen * Germany
Phone/Fax +49-700-68664637 * 0700-MTNMINDS

Registergericht Muenchen * HRA 80201
Mountainminds Verwaltungs GmbH
Registergericht Muenchen * HRB 143183
Geschaeftsfuehrer Marc Hoffmann

Hyunil Shin

unread,
Jun 1, 2016, 9:29:40 PM6/1/16
to JaCoCo and EclEmma Users
Thank you. anyway.

It was about  Class ID.
War file was built in an environment which was different from one of analysis.
- War file was executed with Jacoco agent in build machine.
- One more compile happened for Jenkins Jacoco plugin, which needs source and java classes in test machine.

When I built war file in test machine, it worked.

Because of this issue, I was in trouble almost for two days.
(use different tomcat version, try to use Jetty, change java version, change Jacoco version...
I should have to read more carefully documentations, debug the result using session that you said.)

Thank you again.

Marc R. Hoffmann

unread,
Jun 2, 2016, 12:32:50 AM6/2/16
to jac...@googlegroups.com
Glad to hear that you found the issue!

You may ask the Jenkins developers to add a warning in case of non-matching class files. Our Maven and Ant plugins already do this:

        if (!nomatch.isEmpty()) {
            log.warn(format(
                    "Classes in bundle '%s' do no match with execution data. "
                            + "For report generation the same class files must be used as at runtime.",
                    bundle.getName()));
            for (final IClassCoverage c : nomatch) {
                log.warn(format("Execution data for class %s does not match.",
                        c.getName()));
            }
        }

See: https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin/src/org/jacoco/maven/ReportSupport.java#L210


Regards,
-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.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages