Code Coverage Report for manual testing (Jacoco)

386 views
Skip to first unread message

srira...@gmail.com

unread,
Oct 27, 2016, 6:06:07 AM10/27/16
to JaCoCo and EclEmma Users
Hi,

We are planning to generate Code Coverage reports for our manual testing for the web application hosted on Weblogic.

The intention is that, we want to run some tests on the application and see the code coverage and depending on that, we want to improve our tests.

I have added jacocoagent.jar in setDomainEnv.sh. Then I started the weblogic managed server and the application was up. I logged in into the application and performed some operations and shutdown the AppServer. Now I have a jacoco.exec file.

How do i check the contents of this file? How can this be represented in a xml or html format? We dont have access to the actual source code as we are testers and we dont have automated tests also in this context.

Ccan some one please help me with addressing this issue?

Thanks in advance!

Regards,
Sriram

Marc R. Hoffmann

unread,
Oct 27, 2016, 6:11:01 AM10/27/16
to jac...@googlegroups.com
Hi Sriram,

you need to create an report with the tools provided with JaCoCo. For report generation you need

1) exec files
2) Same class files (or JARs) used at runtime
3) Optionally source files (for hilighting)

JaCoCo comes with a report Maven goal or Ant task. Alternatively you could use the Java API or any other build tool with JaCoCo integration:

Regards,
-marc

srira...@gmail.com

unread,
Oct 31, 2016, 8:02:08 AM10/31/16
to JaCoCo and EclEmma Users

Hi Marc,

As you mentioned, I have used Jacoco.exec and the class files of our product. Coverage Report is successfully generated. But for this, I needed to extract the jars and unzip them and point to that folder. But, in our installation, we only have jar files and class files are not visible, unless we explicitly unzip them.

I tried to include jars but, I always get an error "Error while creating report"

Is there a way that I can generated Code coverage reports for jars but not classes? Iam adding my target code for your convenience.

***********************************************
<target name="report">
<mkdir dir="${jacoco.report.dir}"/>
<jacoco:report>
<executiondata>
<file file="${jacocoexec.fullpath}"/>
</executiondata>

<structure name="Code coverage Report">
<classfiles>
<fileset dir="${classes.dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset file="${src.dir}/*.jar"/>
</sourcefiles>
</structure>

<html destdir="${jacoco.report.dir}"/>
<csv destfile="${jacoco.report.dir}/report.csv"/>
<xml destfile="${jacoco.report.dir}/report.xml"/>

</jacoco:report>
</target>
*************************************************

srira...@gmail.com

unread,
Oct 31, 2016, 8:09:22 AM10/31/16
to JaCoCo and EclEmma Users, srira...@gmail.com
Hi Marc,

Thanks already,

Always B happy,
Sriram

Marc R. Hoffmann

unread,
Oct 31, 2016, 2:11:41 PM10/31/16
to jac...@googlegroups.com
Hi Sriram,

JaCoCo should be fine with JAR files, it will automatically read classe
files from it. Works even recursively e.g for JAR files in WAR files.

To help you it would be useful to see the full error message. There
should be more text after "Error while creating report" with the exact
technical details.

Regards,
-marc

Sri Ram

unread,
Nov 1, 2016, 3:02:45 AM11/1/16
to jac...@googlegroups.com
Hi Marc,


Unfortunately, there are not any details for the failure.

Below is the total error that I got...
**************
Buildfile: D:\ANT\WS\ANTProj\build.xml
report:
[jacoco:report] Loading execution data file D:\ANT\CodeCoverage\jacoco\jacoco_PS3_WLS1.exec

BUILD FAILED
D:\ANT\WS\ANTProj\build.xml:25: Error while creating report

Total time: 1 second
**************

In this case, I have pointed to the directory where jar files are located. But when I picked one the jars, expanded it and pointed to that directory, which contained classes, it worked fine. Below is the code snippet.
******************************
   <structure name="Finally code coverage Report">
       <classfiles>
           <fileset dir="${classes.dir}" />
       </classfiles>
       <sourcefiles encoding="UTF-8">
           <fileset dir="${src.dir}"/>
       </sourcefiles>
   
   </structure>
*******************************

When I googled also, it is mentioned that jars will be automatically taken care of, but this is not working for me and Iam not sure where Iam going wrong or missing something here.

Just check the above code snippets and let me know if Iam doing something wrong.
Thanks!

Always B Happy ,
Sri Ram


--
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/Dsm1n7HwLFo/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/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.

Marc Hoffmann

unread,
Nov 1, 2016, 8:50:29 AM11/1/16
to jac...@googlegroups.com
Hi Sriram,

run Ant with the -debug option and you should get an detailed stack
trace.

Regards,
-marc
>> [1].
>> To unsubscribe from this group and all its topics, send an email to
>> jacoco+un...@googlegroups.com.
>> [2].
>> For more options, visit https://groups.google.com/d/optout [3].
>
> --
> 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/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com
> [4].
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1] https://groups.google.com/d/topic/jacoco/Dsm1n7HwLFo/unsubscribe
> [2]
> https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
> [3] https://groups.google.com/d/optout
> [4]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&utm_source=footer

Sri Ram

unread,
Nov 1, 2016, 10:28:26 AM11/1/16
to jac...@googlegroups.com, Sriram Swaroop B
Hi Marc,

Thanks!
As per your suggestion, I have run ant with debug option and identified that there are some problematic jars due to which the job was failing. I manually deleted them from the folder and ran the task and it was successful.

Now, I want to exclude them from the program as it is not possible to remove them from actual test environment.

I have tried <exclude name="abc.jar"/> and <excludefiles name="abc.jar"/> but both dont seem to work.

Any suggestions here? 
Thanks in advance!

Always B Happy ,
Sri Ram


To view this discussion on the web visit

https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
[2].
For more options, visit https://groups.google.com/d/optout [3].

 --
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
--
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/Dsm1n7HwLFo/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/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com.

Marc Hoffmann

unread,
Nov 1, 2016, 10:37:17 AM11/1/16
to jac...@googlegroups.com
Hi Sri Ram,

this is a regular Ant fileset. See Ant documentation how to configure
includes/excludes correctly:

https://ant.apache.org/manual/Types/fileset.html

Just curious: What was causing the failure? We're always interested in
potential bugs in JaCoCo.

Regards,
-marc
>> jacoco+un...@googlegroups.com.
> [3]
>
>> [2].
>> For more options, visit https://groups.google.com/d/optout [2] [3].
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout [2].
> [1]
> [2]
> https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
> [3]
> [3] https://groups.google.com/d/optout [2]
> [4]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&utm_source=footer
> [5]
>
> --
> 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/Dsm1n7HwLFo/unsubscribe [1].
> 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/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com
> [6].
> For more options, visit https://groups.google.com/d/optout [2].
>
> --
> 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/CADCxQoP2FzhZEcjCyaFSBvyD63hCpwFuc5mcWst2mYGt%2B%3Dhe9A%40mail.gmail.com
> [7].
> [2] https://groups.google.com/d/optout
> [3]
> https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
> [4]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com
> [5]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer
> [6]
> https://groups.google.com/d/msgid/jacoco/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com
> [7]
> https://groups.google.com/d/msgid/jacoco/CADCxQoP2FzhZEcjCyaFSBvyD63hCpwFuc5mcWst2mYGt%2B%3Dhe9A%40mail.gmail.com?utm_medium=email&utm_source=footer

Sri Ram

unread,
Nov 1, 2016, 10:48:32 AM11/1/16
to jac...@googlegroups.com, Sriram Swaroop B
Hi Marc,

Iam not pretty sure but It seems they are 3rd party jars and dont have access permissions to analyze them. Will update once I get a confirmation on this.
I will try with the update that you have provided.
Thank you.

Always B Happy ,
Sri Ram


To view this discussion on the web visit

https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
[3]

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

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

To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com
[6].
For more options, visit https://groups.google.com/d/optout [2].

 --
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
--
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/Dsm1n7HwLFo/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/f9c1f793dc9941f9bcdb9d37824548d8%40mountainminds.com.

Sri Ram

unread,
Nov 1, 2016, 11:03:38 AM11/1/16
to jac...@googlegroups.com, Sriram Swaroop B
Hi Marc,

This is the code snippet that Iam using to exclude certain jars but they dont seem to be exluded and causing the task to fail. Can you tell me where Iam going wrong?

*************
   <structure name="Finally code coverage Report">
       <classfiles>
           <fileset dir="${classes.dir}">
            <exclude name="${classes.dir}\a1.jar"/>
            <exclude name="${classes.dir}\a2.jar"/>
            <exclude name="${classes.dir}\a3.jar"/>
           </fileset>
       </classfiles>
       <sourcefiles>
           <fileset file="${src.dir}\*.jar">

           </fileset>
       </sourcefiles>
   </structure>
            
**************

Always B Happy ,
Sri Ram

Sri Ram

unread,
Nov 1, 2016, 11:27:52 AM11/1/16
to jac...@googlegroups.com, Sriram Swaroop B
Hi Marc,

I got the issue resolved. I was earlier using the absolute path. When I use relative path, it worked.

Thanks a lot for your support!

Always B Happy ,
Sri Ram

Marc Hoffmann

unread,
Nov 1, 2016, 11:53:51 AM11/1/16
to jac...@googlegroups.com
Some hints:

- Are you executing on windows (backslash)? I would use regular slash in
any case.
- also the exclude is given relative to the basedir. So I would write
name="a1.jar" only
- The JAR file is sitting directly under classes dir?

To test the fileset you can e.g. use it as source within a simple copy
task.

Cheers,
-marc

On 2016-11-01 16:03, Sri Ram wrote:
> Hi Marc,
>
>> https://ant.apache.org/manual/Types/fileset.html [1]
>> https://groups.google.com/d/topic/jacoco/Dsm1n7HwLFo/unsubscribe [2]
>> [1]
>> [1].
>> 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/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
>> [3]
>> [3]
>>
>> [2].
>> For more options, visit https://groups.google.com/d/optout [4] [2]
>> [3].
>>
>> --
>> 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.
>> [5]
>> [4]
>> [4].
>> For more options, visit https://groups.google.com/d/optout [4] [2].
>> [2]
>> [3] https://groups.google.com/d/optout [4] [2]
>> [4]
>>
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&utm_source=footer
>> [6]
>> [5]
>>
>> --
>> 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/Dsm1n7HwLFo/unsubscribe [2]
>> [1].
>> To unsubscribe from this group and all its topics, send an email to
>> jacoco+un...@googlegroups.com.
>> [7]
>> [6].
>> For more options, visit https://groups.google.com/d/optout [4] [2].
>>
>> --
>> 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.
>> [8]
>> [7].
>> For more options, visit https://groups.google.com/d/optout [4].
>> [2]
>> [2] https://groups.google.com/d/optout [4]
>> [3]
>>
> https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
>> [3]
>> [4]
>>
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com
>> [5]
>> [5]
>>
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer
>> [9]
>> [6]
>>
> https://groups.google.com/d/msgid/jacoco/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com
>> [7]
>> [7]
>>
> https://groups.google.com/d/msgid/jacoco/CADCxQoP2FzhZEcjCyaFSBvyD63hCpwFuc5mcWst2mYGt%2B%3Dhe9A%40mail.gmail.com?utm_medium=email&utm_source=footer
>> [10]
>
> --
> 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/Dsm1n7HwLFo/unsubscribe [2].
> 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/f9c1f793dc9941f9bcdb9d37824548d8%40mountainminds.com
> [11].
> 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/CADCxQoPPxJBJOUBLD4YEEzJWDT2YXdSohw8M-JSjr-zFNhY76Q%40mail.gmail.com
> [12].
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1] https://ant.apache.org/manual/Types/fileset.html
> [2] https://groups.google.com/d/topic/jacoco/Dsm1n7HwLFo/unsubscribe
> [3]
> https://groups.google.com/d/msgid/jacoco/f71c275a-d99b-90cb-0892-76af21822e6c%40mountainminds.com
> [4] https://groups.google.com/d/optout
> [5]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com
> [6]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&amp;utm_source=footer
> [7]
> https://groups.google.com/d/msgid/jacoco/ba9ae1c396279d9833d5380179eeaaa4%40mountainminds.com
> [8]
> https://groups.google.com/d/msgid/jacoco/CADCxQoP2FzhZEcjCyaFSBvyD63hCpwFuc5mcWst2mYGt%2B%3Dhe9A%40mail.gmail.com
> [9]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPAe%3DbsgJg2Mz3PaNH9ZjAHJC10di%3DVP5G2%3DBM-zZWNpQ%40mail.gmail.com?utm_medium=email&amp;amp;utm_source=footer
> [10]
> https://groups.google.com/d/msgid/jacoco/CADCxQoP2FzhZEcjCyaFSBvyD63hCpwFuc5mcWst2mYGt%2B%3Dhe9A%40mail.gmail.com?utm_medium=email&amp;utm_source=footer
> [11]
> https://groups.google.com/d/msgid/jacoco/f9c1f793dc9941f9bcdb9d37824548d8%40mountainminds.com
> [12]
> https://groups.google.com/d/msgid/jacoco/CADCxQoPPxJBJOUBLD4YEEzJWDT2YXdSohw8M-JSjr-zFNhY76Q%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