Jacoco not showing coverage for all classes.

14,434 views
Skip to first unread message

coolka...@gmail.com

unread,
Oct 22, 2013, 11:50:32 PM10/22/13
to jac...@googlegroups.com
I have a project which I am instrumenting with the agent. I have configured the agent to monitor all my required classes, and the jacoco.exec file is being generated.

My theory is that this is what is happening:
"Why does a class show as not covered although it has been executed?

First make sure execution data has been collected. For this select the Sessions link on the top right corner of the HTML report and check whether the class in question is listed. If it is listed but not linked the class at execution time is a different class file. Make sure you're using the exact same class file at runtime as for report generation. Note that some tools (e.g. EJB containers, mocking frameworks) might modify your class files at runtime."

Now can I configure the agent to dump all the classes it sees and give that to the maven report task to generate the report correctly?

-
Karthik

Marc R. Hoffmann

unread,
Oct 23, 2013, 1:50:16 AM10/23/13
to jac...@googlegroups.com
Hi,

I haven't tried this scenario in Maven before, but we have an parameter
dump classes seen by the agent. See parameter classDumpDir of the
prepare-agent goal:

http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html#classDumpDir

Best regards,
-marc

RobAu

unread,
Oct 23, 2013, 8:32:53 AM10/23/13
to jac...@googlegroups.com
I have similar problems

I created a multi-module maven project with a module that contains all the tests. Running the tests works fine and generates a jacoco.exec file. When I run jacoco:report I get a list of sessions; the sessions contain loaded classes. I also see these classes when I dump them using the classDumpDir.

However, there is no code-coverage data. I tried to manually inspect the jacoco.exec. When visition the bundels (IPackageCoverage p : bundle.getPackages() I get an empty list.

What am I missing?

RobAu

unread,
Oct 23, 2013, 8:38:48 AM10/23/13
to jac...@googlegroups.com
When manually setting the classes dir to the dumped classes dir, I do get output :)

I suppose it could be 'fixed' by providing a parameter to the jacoco:report goal to add 'external' classes folders. Then you could point to the modules you want coverage on.

Marc R. Hoffmann

unread,
Oct 24, 2013, 12:38:04 AM10/24/13
to jac...@googlegroups.com
Hi Rob,

multi module builds are still an open issue: The report goal is
basically designed for simple modules with the tests in the same model.
One of the current work arounds is to use an Ant goal and embed the
report Ant task which then references all the modules containing the
tested code, see for example the JaCoCo build itself:

https://github.com/jacoco/jacoco/blob/master/org.jacoco.doc/pom.xml#L88

Best regards,
-marc
> --
> 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/groups/opt_out.

coolka...@gmail.com

unread,
Oct 25, 2013, 9:26:12 AM10/25/13
to jac...@googlegroups.com
Hello Marc and Rob,

I have been able to get the coverage reports by dumping the classes and use the ant task to use that. My coverage reports are now showing up fine.

But the catch is that source code information is not available in the generated HTML Reports. Here's how my ANT Tasks look like..

https://gist.github.com/KarthikDot/7154630

My Source Code is available in the {src.dir} but the only catch is that this is a multi module project, and there are different folders have the source code...

How can I get the HTML Reports to show the code as well?

Marc R. Hoffmann

unread,
Oct 25, 2013, 10:31:33 AM10/25/13
to jac...@googlegroups.com
Hi,

there might be different reasons, why source code is not linked, see FAQ at http://www.eclemma.org/jacoco/trunk/doc/faq.html

Cheers,
-marc

Why does the coverage report coverage report not show highlighted source code?

Make sure the following prerequisites are fulfilled to get source code highlighting in JaCoCo coverage reports:

  • Class files must be compiled with debug information to contain line numbers.
  • Source files must be properly supplied at report generation time. I.e. specified source folders must be the direct parent of the folders that define the Java packages.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages