Jcoco for Jar instrumentation and coverage generation

439 views
Skip to first unread message

krisha...@gmail.com

unread,
Mar 10, 2015, 6:17:05 AM3/10/15
to jac...@googlegroups.com
Hi all,

Can I use Jacoco for jar instrumentation without using Maven or ant tasks provided.

I know that adding agent jar as JVM option to my server startup script will generate jcoco.exec file. However as per the documentation, to generate coverage report, I need to point class files. Since I don't have source files or class files, only option left is to extract all jar files and put class files to temp directory, and point them at report generation. Is there any better alternative for this ?

Thanks,
Krishantha.

Marc R. Hoffmann

unread,
Mar 10, 2015, 11:35:38 AM3/10/15
to jac...@googlegroups.com
Where do you "extract all JAR files" from?

Note that by default the JaCoCo reporting Ant task or Maven goal will
recursively search EAR/WAR/JAR files for class files.

Regards,
-marc

Krishantha Samaraweera

unread,
Mar 12, 2015, 4:55:56 AM3/12/15
to jac...@googlegroups.com
Hi Marc,

Thanks for your prompt reply.

I'm trying to use ant task as below by giving path to server side jar files directory. However jacoco doesn't generate the coverage report correctly. The generated xml report has zero coverage data. Note that jacoco.exec file is not empty and its size is around 414K. Let me know whether my jacoco-report ant task is valid ? do I need to point valid project structure name here for "structure name". Since I'm trying to generate server side code coverage my project has only test classes to call server side APIs.

<jacoco-report>
        <executiondata>
            <file file="${project.basedir}/target/jacoco.exec"/>
        </executiondata>
        <structure name="Minerva">
            <classfiles>
            <fileset dir="/path/to/jar/directory/in/my/extracted/server/">
                <include name="**/*.jar"/>
            </fileset>
            </classfiles>
        </structure>
        <html destdir="${project.basedir}/target/jacoco/report"/>
        <xml destfile="${project.basedir}/target/jacoco/report/jacoco.xml"/>
    </jacoco-report>


Your feedback really appreciated.

Thanks,
Krishantha.

--
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/BmMFpFG0vdY/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/54FF0F56.1070309%40mountainminds.com.

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

Marc R. Hoffmann

unread,
Mar 12, 2015, 3:37:05 PM3/12/15
to jac...@googlegroups.com
Hi,

when you open the HTML report:

1) Are your packages and classes listed (even with 0% coverage) or is the report empty?
2) Click on the "Sessions" link on the top right. Are your classes under test listed? Do they have links?

In case of 0% coverage you'll find some background information here: http://www.eclemma.org/jacoco/trunk/doc/classids.html

Regards,
-marc

Krishantha Samaraweera

unread,
Mar 13, 2015, 8:51:53 AM3/13/15
to jac...@googlegroups.com
Hi Marc,

I debugged the Jacoco ant task code and found the problem. My jar list has more than 150+ jars which contain 10K of classes. Execution terminated abnormally at analyzeZip() method. May be the load is too high. I will try to provide a patch with fixes.

When reduce the jar list size coverage generation works.

Thanks for your help.

-Krishantha.

--
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/BmMFpFG0vdY/unsubscribe.
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/5501EADE.30901%40mountainminds.com.

Marc R. Hoffmann

unread,
Mar 13, 2015, 2:53:07 PM3/13/15
to jac...@googlegroups.com
Hi Krishantha,

do you get a specific error message? 10k of classes shouldn't be an issue, report generation is fully based on streaming.

Regards,
-marc

Krishantha Samaraweera

unread,
Mar 13, 2015, 3:10:24 PM3/13/15
to jac...@googlegroups.com
Hi Marc,

On Sat, Mar 14, 2015 at 12:23 AM, Marc R. Hoffmann <hoff...@mountainminds.com> wrote:
Hi Krishantha,

do you get a specific error message? 10k of classes shouldn't be an issue, report generation is fully based on streaming.

No error messages got printed. Need to profile and see what is going wrong. I didn't get much time to dig into the issue yet.

Thanks,
Krishantha.
 

--
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/BmMFpFG0vdY/unsubscribe.
To unsubscribe from this group and all its topics, 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