0 % shown in the code coverage

1,066 views
Skip to first unread message

leoy...@gmail.com

unread,
Mar 31, 2015, 6:38:32 PM3/31/15
to jac...@googlegroups.com
Hi,
I am having problem to generate a coverage report when running tomcat with jacoco.
I have set up tomcat to run with the jacoco agent with this param: -javaagent:/Users/leo_chan/dev/jacoco/lib/jacocoagent.jar=output=tcpserver,address=*,port=6300,dumponexit=false,append=false,..."

Then I used maven to kick of a testng test that hit a url which will in return invoke my controller running in tomcat. Then maven task will dump the exec file and generate the report. I can see that exec file is generated and but the final report snow 0 of 0 coverage. On the sessions report page, it does show my controller class in the "Execution data for the following classes is considered in this report:" section.
Class Id
....accessservice.controller.HeartbeatController cac6fb3c4204f6d9


But the main report only shows:
Element Missed Instructions Cov. Missed Branches Cov.
Total 0 of 0 n/a 0 of 0 n/a

I check the target/classes folder and check the controller class is the same one used in tomcat. Why is the report shows 0 coverage? What am I missing?

One thing is that the exec file doesn't seem to have a lot of information:
??MacBook-Pro.local-9822958fLqb?TLqcm???<B??=com/.../nsp/accessservice/controller/HeartbeatController??MacBook-Pro.local-224c5111Lqle?Lqlܙ???<B??=com/.../nsp/accessservice/controller/HeartbeatController??

Thanks for your help.

Leo

qunf...@gmail.com

unread,
Apr 1, 2015, 1:26:53 AM4/1/15
to jac...@googlegroups.com, leoy...@gmail.com
在 2015年4月1日星期三 UTC+8上午6:38:32,leoy...@gmail.com写道:
Did you shutdown your Tomcat at last step?
http://stackoverflow.com/questions/6856744/getting-code-coverage-of-my-application-using-jacoco-java-agent-on-tomcat

Marc Hoffmann

unread,
Apr 1, 2015, 5:26:15 AM4/1/15
to jac...@googlegroups.com
Hi Leo,

on the Sessions page, is the class HeartbeatController linked to the
report or is it just plain text?

If it is not linked this means the JaCoCo agent sees a different class
file than the one used for report generation.

BTW, the exec file is a internal binary format. You can open exec files
with the EclEmma plugin or dump the content with this example program:
http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java

Regards,
-marc

leo chan

unread,
Apr 1, 2015, 9:46:44 AM4/1/15
to jac...@googlegroups.com
Hi Mac,
  Thanks for the reply.  Yes the class in the report is plain text.  I actually use the classdumpdir option in the agent start up to dump the HeartBeatController class file and then put that into the target/classes folder to make sure it is the same class but still get the same result.  I also do a diff on the heartBeatController class to the one in tomcat, it is the same.    It there a way that I can make sure I am using the right one beside what I just did? 

Leo



--
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/lUCS9vUquBM/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/9e39d6a5ae8cd163777748ac3847c486%40mountainminds.com.

For more options, visit https://groups.google.com/d/optout.

Marc Hoffmann

unread,
Apr 1, 2015, 10:05:47 AM4/1/15
to jac...@googlegroups.com
Hi Leo,

if it is not linked this means the class file used at runtime is
different from the class file used at reporting time.

If already use the classdumpdir option I can't really see what's going
wrong. There is a another utility in our examples which shows the id of
given class file. This might help to track where the difference comes
in:

http://www.eclemma.org/jacoco/trunk/doc/examples/java/ClassInfo.java

Regards,
-marc

On 2015-04-01 15:46, leo chan wrote:
> Hi Mac,
> Thanks for the reply. Yes the class in the report is plain text. I
> actually use the classdumpdir option in the agent start up to dump the
> HeartBeatController class file and then put that into the
> target/classes folder to make sure it is the same class but still get
> the same result. I also do a diff on the heartBeatController class to
> the one in tomcat, it is the same. It there a way that I can make
> sure I am using the right one beside what I just did?
>
> Leo
>
> On Wed, Apr 1, 2015 at 5:26 AM, Marc Hoffmann
> <hoff...@mountainminds.com> wrote:
>
>> Hi Leo,
>>
>> on the Sessions page, is the class HeartbeatController linked to
>> the report or is it just plain text?
>>
>> If it is not linked this means the JaCoCo agent sees a different
>> class file than the one used for report generation.
>>
>> BTW, the exec file is a internal binary format. You can open exec
>> files with the EclEmma plugin or dump the content with this example
>> program:
>> http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java
>> [1]
>> [2].
>> To unsubscribe from this group and all its topics, send an email to
>> jacoco+un...@googlegroups.com.
>> [3].
>>
>> For more options, visit https://groups.google.com/d/optout [4].
>
> --
> 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/CANWomOEReCatFPznoZDAVuSkn7vfCcDb4Z5gavAh%2BiR-7wAhcg%40mail.gmail.com
> [5].
> For more options, visit https://groups.google.com/d/optout [4].
>
>
> Links:
> ------
> [1] http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java
> [2] https://groups.google.com/d/topic/jacoco/lUCS9vUquBM/unsubscribe
> [3]
> https://groups.google.com/d/msgid/jacoco/9e39d6a5ae8cd163777748ac3847c486%40mountainminds.com
> [4] https://groups.google.com/d/optout
> [5]
> https://groups.google.com/d/msgid/jacoco/CANWomOEReCatFPznoZDAVuSkn7vfCcDb4Z5gavAh%2BiR-7wAhcg%40mail.gmail.com?utm_medium=email&utm_source=footer

leo chan

unread,
Apr 1, 2015, 10:08:20 AM4/1/15
to jac...@googlegroups.com
Hi Marc,
   I figured out the problem.  It turns out it is an pom.xml issue.  In the report-integration goal.  I think my includes option is wrong.  I took that out and the generated report show coverage and link now.  Thanks for your help.

Leo


To view this discussion on the web visit

https://groups.google.com/d/msgid/jacoco/9e39d6a5ae8cd163777748ac3847c486%40mountainminds.com
[3].

For more options, visit https://groups.google.com/d/optout [4].

 --
 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,

 To view this discussion on the web visit
--
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/lUCS9vUquBM/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/39f875b0e87909c7248a74bdd3777a0d%40mountainminds.com.

For more options, visit https://groups.google.com/d/optout.

leo chan

unread,
Apr 1, 2015, 10:37:40 AM4/1/15
to jac...@googlegroups.com
Hi Marc,
   One follow up question.  Is there a way to tell maven to look into a war file instead of the target/classes directory for classes when generating the report? 


Marc Hoffmann

unread,
Apr 2, 2015, 7:30:49 AM4/2/15
to jac...@googlegroups.com
Ciao Leo,

JaCoCo core processes archive files recursively. The maven plugin
processes all files from the build output directory. If you configure
the build output to the location of your WAR file JaCoCo should pick it
up here.

For details maybe our Maven wizards can jump in here?

Regards,
-marc



On 2015-04-01 16:37, leo chan wrote:
> Hi Marc,
> One follow up question. Is there a way to tell maven to look into
> a war file instead of the target/classes directory for classes when
> generating the report?
>
> On Wed, Apr 1, 2015 at 10:08 AM, leo chan <leoy...@gmail.com> wrote:
>
>> Hi Marc,
>> I figured out the problem. It turns out it is an pom.xml issue.
>> In the report-integration goal. I think my includes option is
>> wrong. I took that out and the generated report show coverage and
>> link now. Thanks for your help.
>>
>> Leo
>>
>> On Wed, Apr 1, 2015 at 10:05 AM, Marc Hoffmann
>> <hoff...@mountainminds.com> wrote:
>> Hi Leo,
>>
>> if it is not linked this means the class file used at runtime is
>> different from the class file used at reporting time.
>>
>> If already use the classdumpdir option I can't really see what's
>> going wrong. There is a another utility in our examples which shows
>> the id of given class file. This might help to track where the
>> difference comes in:
>>
>> http://www.eclemma.org/jacoco/trunk/doc/examples/java/ClassInfo.java
>> [2]
>> [3]
>> [2].
>> To unsubscribe from this group and all its topics, send an email to
>> jacoco+un...@googlegroups.com.
> [5]
>
>> [3].
>>
>> For more options, visit https://groups.google.com/d/optout [4] [4].
>
> --
> 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.
> [6]
> [5].
> For more options, visit https://groups.google.com/d/optout [4] [4].
> [2] https://groups.google.com/d/topic/jacoco/lUCS9vUquBM/unsubscribe
> [3]
> [3]
>
> https://groups.google.com/d/msgid/jacoco/9e39d6a5ae8cd163777748ac3847c486%40mountainminds.com
> [5]
> [4] https://groups.google.com/d/optout [4]
> [5]
>
> https://groups.google.com/d/msgid/jacoco/CANWomOEReCatFPznoZDAVuSkn7vfCcDb4Z5gavAh%2BiR-7wAhcg%40mail.gmail.com?utm_medium=email&utm_source=footer
> [7]
>
> --
> 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/lUCS9vUquBM/unsubscribe [3].
> 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/39f875b0e87909c7248a74bdd3777a0d%40mountainminds.com
> [8].
>
> For more options, visit https://groups.google.com/d/optout [4].
>
> --
> 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/CANWomOHMyaQdVFATuvKrJjWq6qjyE%3DM%3D%3Dc_exGBF_vk7Zn7J0g%40mail.gmail.com
> [9].
> For more options, visit https://groups.google.com/d/optout [4].
>
>
> Links:
> ------
> [1]
> http://www.eclemma.org/jacoco/trunk/doc/examples/java/ClassInfo.java
> [2] http://www.eclemma.org/jacoco/trunk/doc/examples/java/ExecDump.java
> [3] https://groups.google.com/d/topic/jacoco/lUCS9vUquBM/unsubscribe
> [4] https://groups.google.com/d/optout
> [5]
> https://groups.google.com/d/msgid/jacoco/9e39d6a5ae8cd163777748ac3847c486%40mountainminds.com
> [6]
> https://groups.google.com/d/msgid/jacoco/CANWomOEReCatFPznoZDAVuSkn7vfCcDb4Z5gavAh%2BiR-7wAhcg%40mail.gmail.com
> [7]
> https://groups.google.com/d/msgid/jacoco/CANWomOEReCatFPznoZDAVuSkn7vfCcDb4Z5gavAh%2BiR-7wAhcg%40mail.gmail.com?utm_medium=email&amp;utm_source=footer
> [8]
> https://groups.google.com/d/msgid/jacoco/39f875b0e87909c7248a74bdd3777a0d%40mountainminds.com
> [9]
> https://groups.google.com/d/msgid/jacoco/CANWomOHMyaQdVFATuvKrJjWq6qjyE%3DM%3D%3Dc_exGBF_vk7Zn7J0g%40mail.gmail.com?utm_medium=email&utm_source=footer

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