Discussion:
Jacoco not showing coverage for all classes.
c***@public.gmane.org
2013-10-23 03:50:32 UTC
Permalink
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
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Marc R. Hoffmann
2013-10-23 05:50:16 UTC
Permalink
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
Post by c***@public.gmane.org
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.
"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
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
RobAu
2013-10-23 12:32:53 UTC
Permalink
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?
Post by Marc R. Hoffmann
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
http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html#classDumpDir
Best regards,
-marc
Post by c***@public.gmane.org
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.
Post by c***@public.gmane.org
"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."
Post by c***@public.gmane.org
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?
Post by c***@public.gmane.org
-
Karthik
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
RobAu
2013-10-23 12:38:48 UTC
Permalink
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
Marc R. Hoffmann
2013-10-24 04:38:04 UTC
Permalink
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
Post by RobAu
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.
--
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
For more options, visit https://groups.google.com/groups/opt_out.
c***@public.gmane.org
2013-10-25 13:26:12 UTC
Permalink
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?
Post by Marc R. Hoffmann
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
https://github.com/jacoco/jacoco/blob/master/org.jacoco.doc/pom.xml#L88
Best regards,
-marc
Post by RobAu
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.
--
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
For more options, visit https://groups.google.com/groups/opt_out.
Marc R. Hoffmann
2013-10-25 14:31:33 UTC
Permalink
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.
Post by c***@public.gmane.org
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?
Post by Marc R. Hoffmann
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
https://github.com/jacoco/jacoco/blob/master/org.jacoco.doc/pom.xml#L88
Best regards,
-marc
Post by RobAu
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.
--
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
For more options, visit https://groups.google.com/groups/opt_out.
--
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Loading...