Get csv report from command-line usage of JaCoCo

8,456 views
Skip to first unread message

Spyros

unread,
Jun 11, 2013, 1:16:20 PM6/11/13
to jac...@googlegroups.com
Hello everyone,

I don't know if this has been asked before; from a quick search I couldn't find anything relevant, but please do forgive me if I've missed it.

My question is, is there any way to get the .csv report from calling JaCoCo from the command-line? For example, say I have the following:

java -javaagent:/home/jacoco/lib/jacocoagent.jar HelloWorld

Is there any option that can generate the csv report, in addition to the .exec file? Moreover, is there any way of "translating" the .exec binary file to a .csv report, if we are not using Eclipse?

Thanks in advance, and I do apologize again if this has been asked and answered before,

Spyros

Marc R. Hoffmann

unread,
Jun 11, 2013, 2:21:44 PM6/11/13
to jac...@googlegroups.com
Hi Spyros,

the exec file as such is not enough to create a csv file. JaCoCo also
needs all class files under test (the agent only sees the ones actually
loaded).

So there is always a second step called report generation. Beside
EclEmma you can also use the JaCoCo Ant task or Maven goal to create a
csv report, see:

- http://www.eclemma.org/jacoco/trunk/doc/ant.html
- http://www.eclemma.org/jacoco/trunk/doc/maven.html

We do not yet have a pure command line tool for report generation,
though we have a pending pull request and will work on this.

BTW, you can dump the plain content of the exec file but this will not
provide too useful information. Here is an example Java program:

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

Best regards,
-marc

spyros.hadji...@logicblox.com

unread,
Jun 11, 2013, 2:28:32 PM6/11/13
to jac...@googlegroups.com, spyros.hadji...@logicblox.com
Hi Marc,

First of all, thank you for the prompt response, I really appreciate it :)

My problem is that I'm not very comfortable with building large Java projects yet, so I'm trying to tweak existing makefiles and bash scripts to make things happen. Such an option to be able to generate full reports just using the command-line -javaagent option would be quite helpful imho...:)

Thanks again for all the help, and for the sample Java program you provided me with!

Spyros

Marc R. Hoffmann

unread,
Jun 11, 2013, 2:39:03 PM6/11/13
to jac...@googlegroups.com
Here is an example build script:

http://www.eclemma.org/jacoco/trunk/doc/examples/build/build.xml

You only need the report target of course. Also there is no need to
specify Java source files and you can remove the html and xml output.

Best regards,
-marc

spyros.hadji...@logicblox.com

unread,
Jun 11, 2013, 2:48:59 PM6/11/13
to jac...@googlegroups.com
Hi Marc,

Thanks again :) This is the example build.xml I've been using as a template. Anyway, I don't know where things are going wrong - the .exec file seems to be generated and contains data, but the .csv one just contains the names of each column...

Thanks again for all the help :)

Spyros

Marc R. Hoffmann

unread,
Jun 11, 2013, 2:58:51 PM6/11/13
to jac...@googlegroups.com
This means the set of supplied classes is empty. Make sure the fileset
points to the correct location.

spyros.hadji...@logicblox.com

unread,
Jun 11, 2013, 3:01:13 PM6/11/13
to jac...@googlegroups.com
Yep, that's what I meant when I said before that I'm not yet comfortable with building Java projects yet - this is what I've been trying to figure out :-)

Again, thanks for all the help,

Spyros

Marc R. Hoffmann

unread,
Jun 11, 2013, 3:07:41 PM6/11/13
to jac...@googlegroups.com
Ant has an excellent manual: http://ant.apache.org/manual/index.html

Also if you're not sure what's going on the echo task allows you to
print variables. Also if you add the -debug option when executing Ant
you will see a lot more information.

-marc

spyros.hadji...@logicblox.com

unread,
Jun 11, 2013, 3:09:06 PM6/11/13
to jac...@googlegroups.com
Perfect, you've given me more than enough to dig deeper :-)

Again, many thanks!

Spyros

irfanam...@gmail.com

unread,
Feb 1, 2016, 9:58:25 AM2/1/16
to JaCoCo and EclEmma Users
Oh!! There isn't any command line to generate the report.....?? Bit disappointing !!
I thought I am doing something wrong and so I am getting following exception:

Caused by: java.lang.IllegalArgumentException: Unknown agent option "dataFile".
at org.jacoco.agent.rt.internal_b0d6a23.core.runtime.AgentOptions.<init>
(AgentOptions.java:210)
at org.jacoco.agent.rt.internal_b0d6a23.PreMain.premain(PreMain.java:43)

... 6 more

Anyways, thanks for the reply.

Marc R. Hoffmann

unread,
Feb 1, 2016, 1:36:37 PM2/1/16
to jac...@googlegroups.com
There is no command line tool to create reports. Normally those reports
are created as part of a build (Ant, Maven etc).

There is no agent option "dataFile", it is called "destfile". Please see
documentation:

http://eclemma.org/jacoco/trunk/doc/agent.html

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