jacoco + tomcat8 reporting zero coverage

45 views
Skip to first unread message

Shiny Sudar

unread,
Dec 3, 2017, 11:39:07 PM12/3/17
to jac...@googlegroups.com
Hello,

Following is the arguments which I add to Java arguments of tomcat : -javaagent:<path of jacoco folder>/lib/jacocoagent.jar=append=true,output=tcpserver,address=localhost,port=36320,includes=*

Im using jacoco as above. Previously it was working fine with tomcat 7  and java 8 and I was getting code coverage information.

But now I had to upgrade to tomcat  8.0.26.08 and Java  1.8.0_131-b11. Now I'm always getting zero coverage. Can anyone help pls?

Is there any log or something which I use for troubleshooting

Thanks,

Angel


Evgeny Mandrikov

unread,
Dec 4, 2017, 7:55:51 AM12/4/17
to JaCoCo and EclEmma Users
In absence of specification of JaCoCo version - first of all please make sure that you use latest released version that is 0.7.9 as of today.

You showed only part that is related to agent, but nothing about generation of report, so:

Given that you use "output=tcpserver" which is according to documentation at http://www.jacoco.org/jacoco/trunk/doc/agent.html

tcpserver: The agent listens for incoming connections on the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.

make sure that you do actually connect and dump execution data. And that you do this after actual execution of tests and not before.

Make sure that dump is not empty, has significant size.

During generation of report make sure that you actually use the dump obtained on previous step and not some other.

Make sure that there is no warnings during generation of report. In particular make sure that report is generated using exact same class files that are deployed into your tomcat. At http://www.jacoco.org/jacoco/trunk/doc/classids.html you can read more about why this is important and how to detect such problem:

How can I detect that I have a problem with class ids?

The typical symptom of class id mismatch is classes not shown as covered although they have been executed during the test. This situation can be easily detected e.g. in the HTML report: Open the Sessions page with the link on the top-right corner. You see a list of all classes where execution data has been collected for. Find the class in questions and check whether the entry has a link to the corresponding coverage report page. If the entry is not linked this means there is a class id mismatch between the class used at runtime and the class provided to create the report.


Regards,
Evgeny

an...@geoconcept.com

unread,
Dec 5, 2017, 2:22:42 AM12/5/17
to JaCoCo and EclEmma Users
Thanks for your reply.
I'm using the latest version of jacoco 0.7.9.
I made sure the exec file generated is not empty its around 50MB,
I write the reports to html forms using the lines below:

DumpCoverage cover = new DumpCoverage();
cover.createCoverageDump(tcpserver, port, coverageResultPath + "/" + coverageDumpFileName, append, retryCount);

// create the coverage resport
final ReportGenerator generator3 = new ReportGenerator(coverageResultPath, coverageDumpFileName, classesDirectory,
sourcesDirectory);
generator3.create();

Im using jacoco-maven plugin 0.7.9 for writing the reports.

I can get the list of classes and functions, only problem is that it remains the same with 0 coverage even after performing some actions on the webapplication

This was working before with tomcat 7 previously.

I dont get any sort of warning or error message. Is there any sort of logs I can check for it?

Please let me know if there is any compatibility issues with tomcat 8


Thank you,
Angel

Evgeny Mandrikov

unread,
Dec 5, 2017, 3:31:57 AM12/5/17
to JaCoCo and EclEmma Users


On Tuesday, December 5, 2017 at 8:22:42 AM UTC+1, an...@geoconcept.com wrote:
Thanks for your reply.
I'm using the latest version of jacoco 0.7.9.
I made sure the exec file generated is not empty its around 50MB,
I write the reports to html forms using the lines below:

DumpCoverage cover = new DumpCoverage();
cover.createCoverageDump(tcpserver, port, coverageResultPath + "/" + coverageDumpFileName, append, retryCount);

// create the coverage resport
final ReportGenerator generator3 = new ReportGenerator(coverageResultPath, coverageDumpFileName, classesDirectory,
   sourcesDirectory);
generator3.create();

Im using jacoco-maven plugin 0.7.9 for writing the reports.


I don't get why you are claiming usage of jacoco-maven-plugin for generation of report and at the same time provide some snippet of custom code to do this?
 

I can get the list of classes and functions, only problem is that it remains the same with 0 coverage even after performing some actions on the webapplication

This was working before with tomcat 7 previously.

I dont get any sort of warning or error message. Is there any sort of logs I can check for it?


If you use your own code for generation of report, then how we can tell which logs/warnings you should check?

Anyway as was explained before: please check that classes used during generation of the report are the same as were deployed into tomcat (by exploring "sessions" page in the report as was explained before) - this is most common mistake.
 

Please let me know if there is any compatibility issues with tomcat 8


As far as I know there is no compatibility issue with Tomcat 8 and people successfully use JaCoCo with it.

Alternatively please provide minimal, but full and complete and easily runnable example ( https://stackoverflow.com/help/mcve ) that demonstrates your difficulty.

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