How to generate code coverage report when only binary of source is available

1,368 views
Skip to first unread message

JococoUser

unread,
Jun 21, 2017, 9:19:20 AM6/21/17
to JaCoCo and EclEmma Users

Hello 

I have a scenario where I am just having binary ( no source code ) to run my integration tests on , using maven .
I want to generate code coverage report using jacoco . 
Have searched through a lot , found examples when your source code is in different module than integration tests ( then use report-aggregate goal ) .
But haven't found anything related to when you don't have source code available and just the binary .
It should work as mentioned in Jacoco documentation -" Based on Java byte code and therefore works also without source files."

Please suggest !

Regards,

Marc R. Hoffmann

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

it should be possible to create any report without source code. You simply get no source highlighting in the html report.

If this does not work for you, please provide a exact description of your setup.

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/1fcf39fd-f1d9-4bb3-898a-0f2b52749c93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neha B

unread,
Jun 22, 2017, 2:49:50 AM6/22/17
to jac...@googlegroups.com
Hi Marc

Thanks so much for the response !

In my setup , I have Integration Tests code in a different Eclipse project , and Development Source Code in a different Eclipse project altogether . Could you please help how Jacoco can be used in this setup to gauge integration test code coverage . 
Thanks .

Regards,

On Wed, Jun 21, 2017 at 8:53 PM, Marc R. Hoffmann <hoff...@mountainminds.com> wrote:
Hi,

it should be possible to create any report without source code. You simply get no source highlighting in the html report.

If this does not work for you, please provide a exact description of your setup.

Regards,
-marc

On 21.06.17 15:19, JococoUser wrote:

Hello 

I have a scenario where I am just having binary ( no source code ) to run my integration tests on , using maven .
I want to generate code coverage report using jacoco . 
Have searched through a lot , found examples when your source code is in different module than integration tests ( then use report-aggregate goal ) .
But haven't found anything related to when you don't have source code available and just the binary .
It should work as mentioned in Jacoco documentation -" Based on Java byte code and therefore works also without source files."

Please suggest !

Regards,
--
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+unsubscribe@googlegroups.com.

--
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/5IqM4AibmT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/d108a325-5f2c-c344-a0fb-e1dc0b8117c3%40mountainminds.com.

Neha B

unread,
Jun 22, 2017, 4:45:14 AM6/22/17
to jac...@googlegroups.com
Basically , my application war file is deployed in server , and I run integration tests through Jenkins on that server . 
Please let me know how to go ahead with Jacoco code coverage in this scenario .

Regards,

Marc Hoffmann

unread,
Jun 22, 2017, 7:21:05 AM6/22/17
to jac...@googlegroups.com

What build system do you use to run your integration tests? Ant, Maven?

Please see our documentation for different build systems:

http://www.jacoco.org/jacoco/trunk/doc/

Regards,
-marc

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/CAGi%2Bcio9TiLr7cqVvgPWt3wTPwq1Gmm%3D7jyGUij%2BV6v6kBN-wQ%40mail.gmail.com.

Neha B

unread,
Jun 28, 2017, 4:28:09 AM6/28/17
to jac...@googlegroups.com
Hi Marc

Please find my configuration below ( Using Maven )  :

1. Started Jacoco javaagent with JBoss ( as JAVA_OPTS args , output set to tcpserver ) , deployed my source .war file on this server  .
2. Changed my Integration tests' pom.xml to include jacoco-maven-plugin , added  phase - post -integration-test  , goals : dump ( from tcpserver ) , and report .

With these changes , I am able to generate a coverage report .
But , the report shows classes from Integraiton Tests ( rather than the source code classes ) , and coverage is 0% 

Could you please help where I am going wrong .

 

--
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/5IqM4AibmT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

Evgeny Mandrikov

unread,
Jun 28, 2017, 4:35:12 AM6/28/17
to JaCoCo and EclEmma Users
Hi,

Report goal uses classes of module where it is executed and hence generates report containing them. I assume that your "integration tests" module has no source classes, so the behavior that you observe is a correct one.

To have a report that includes classes of other modules within Maven reactor please use report-aggregate (http://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html). In complex scenarios/setups to have a more fine grained control of what is used (classes, sources) for generation of report consider usage of JaCoCo Ant Tasks (http://www.jacoco.org/jacoco/trunk/doc/ant.html).

Neha B

unread,
Jun 28, 2017, 4:41:08 AM6/28/17
to jac...@googlegroups.com
Thanks Evgeny . 

I have source code in a different Maven project , packaged as war , while Integration tests in different Maven Project ( maintained by offshore teams ) . In such scenario , how do I use report-aggregate ( when I can't define Parent Module in integration tests' POM ) . 

Also , I have a general question : I am using Jbehave for integration tests . Will Jacoco support Jbehave Tests ? 

Regards,
neha

Evgeny Mandrikov

unread,
Jun 28, 2017, 4:48:58 AM6/28/17
to JaCoCo and EclEmma Users


On Wednesday, June 28, 2017 at 10:41:08 AM UTC+2, JococoUser wrote:
Thanks Evgeny . 

I have source code in a different Maven project , packaged as war , while Integration tests in different Maven Project ( maintained by offshore teams ) . In such scenario , how do I use report-aggregate ( when I can't define Parent Module in integration tests' POM ) . 

In such scenario as was said before: In complex scenarios/setups to have a more fine grained control of what is used (classes, sources) for generation of report consider usage of JaCoCo Ant Tasks (http://www.jacoco.org/jacoco/trunk/doc/ant.html).
Directly from Ant or for example via maven-antrun-plugin.

 
Also , I have a general question : I am using Jbehave for integration tests . Will Jacoco support Jbehave Tests ? 

JaCoCo is completely independent from any testing framework. So yes - it should work.

Neha B

unread,
Jun 29, 2017, 2:09:33 AM6/29/17
to jac...@googlegroups.com
Thanks for this info , Evgeny .

I made the change , and now using maven-antrun-plugin to add class files , and now I see them included .

However , even though I am giving classfiles extracted from same .war file that has been deployed and used during execution , I am getting error message : "Classes in bundle 'Jacocoreport' do no match with execution data. For report generation the same class files must be used as at runtime.  " 
Any clue why I am getting this ?

Also , when I pass on path to .war file directly ( as <file file = ""/> )  instead of extracting classes and pointing to them , I am getting error message : Error while creating report .

Any pointers will really help . Thanks a lot 

Regards
Neha

--
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/5IqM4AibmT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

Evgeny Mandrikov

unread,
Jun 29, 2017, 3:20:33 AM6/29/17
to JaCoCo and EclEmma Users


On Thursday, June 29, 2017 at 8:09:33 AM UTC+2, JococoUser wrote:
Thanks for this info , Evgeny .

I made the change , and now using maven-antrun-plugin to add class files , and now I see them included .

However , even though I am giving classfiles extracted from same .war file that has been deployed and used during execution , I am getting error message : "Classes in bundle 'Jacocoreport' do no match with execution data. For report generation the same class files must be used as at runtime.  " 
Any clue why I am getting this ?

Read documentation about class ids - http://www.jacoco.org/jacoco/trunk/doc/classids.html

 
Also , when I pass on path to .war file directly ( as <file file = ""/> )  instead of extracting classes and pointing to them , I am getting error message : Error while creating report .
 
Run build in verbose mode to see the underlying exception.

Neha B

unread,
Jun 29, 2017, 9:22:44 AM6/29/17
to jac...@googlegroups.com
Thanks Evgeny !

I am able to generate report now using "classdumpdir" , but report is only showing coverage for static blocks .
Any pointer why it may be so .

Regards
Neha

--
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/5IqM4AibmT8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jacoco+unsubscribe@googlegroups.com.

Evgeny Mandrikov

unread,
Jun 30, 2017, 10:31:55 AM6/30/17
to JaCoCo and EclEmma Users
Let's come back to the basics of how everything works:

source file is compiled into non-instrumented class file
non-instrumented class file is instrumented (either pre-instrumented offline, or automatically at runtime by Java agent)
execution of instrumented classes collected into exec file
report decorates source files with information obtained from analysis of exec file and original non-instrumented class files

Message "Classes ... do no match with execution data." during generation of report means that class files used for generation of report are not the same as classes prior to instrumentation. Why match is important? Because otherwise there is no guarantee that what was analyzed matches the sources that were compiled.

"classdumpdir" allows to capture classes that were seen by agent prior to instrumentation.

Following the above sentences, if without "classdumpdir" there were messages about missmatch, then it is strange to expect that analysis of classes obtained with "classdumpdir" will match the sources and will not be weird.

So the main question that you should answer to solve your difficulties - what in your setup/configuration causes this mismatch?

As a helper: HTML report has Sessions page (link on the top-right corner) that displays ids of classes (obtained from exec file) prior to instrumentation. You can use them for comparison with classes on your disk that you try to use for generation of a report.

All in all: please take time to digest documentation and information in this thread to understand how things work and to pinpoint what is causing troubles in your environment/scenario instead of trying things randomly and rushing with questions.

If all this information is not enough, then please provide minimalistic, compilable, complete and easily runnable example demonstrating your issue.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages