Jacoco.exe file is empty

2,101 views
Skip to first unread message

know...@gmail.com

unread,
Jun 2, 2015, 9:38:26 AM6/2/15
to jac...@googlegroups.com
Hi all,

I am trying to use Jacoco to measure test coverage of our small number of tests. I am using Buildr along with the JAVA_OPTS set to "-javaagent:/path/to/jacocoagent.jar". The defaults for Jacoco creates a new jacoco.exec file in the current directory. However this file is empty with 0 bytes. If I use the classdumpdir option, I do see the various test classes placed into the dump directory.

Why then, is the jacoco.exec file not getting filled with data? I have seen one other place mentioning that jvm needs to be shutdown in order to dump the data to that file. Does anyone else have experience with Jacoco through the java agent. We do not use Maven or Ant, as Buildr is what we use for our builds and tests.

Side question - I understand that Jacoco is the freshest method to use for Java test coverage, as opposed to others such as Cobertura and Clover. Is Jacoco the best way to go?

Thank you.

Evgeny Mandrikov

unread,
Jun 2, 2015, 11:59:15 AM6/2/15
to jac...@googlegroups.com, know...@gmail.com, know...@gmail.com
Hi,

At start JaCoCo creates file with a zero size to ensure that location is writable, then it uses "Runtime.addShutdownHook" to write data at the end of JVM execution, but indeed if JVM is not terminated properly, then shutdown hooks are not guaranteed to be executed. However there are other methods of requesting data - see "Can I collect coverage information without stopping the JVM?" in our FAQ ( http://www.eclemma.org/jacoco/trunk/doc/faq.html ). Also if you able to provide simple/minimalistic example of a reproducer of your problem with Buildr, then might be possible to check it precisely. Also seems that there are some work on seamless integration of JaCoCo with Buildr - see https://github.com/apache/buildr/blob/master/addon/buildr/jacoco.rb , so that you might check with authors of this addon.

Could be noted that as far as I know Cobertura also uses shutdown hook and also has troubles, if JVM isn't terminated properly.

What is the best coverage tool probably should be decided by users and not by JaCoCo developers, so I leave this question unanswered ;)

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