Hi Seamus,
what you referring to are so called 'groups'. You can define an
arbitraty hierarchy of groups above packages. Currently this is only
supported by the Ant task
(http://www.eclemma.org/jacoco/trunk/doc/ant.html#report) and the
EclEmma Eclipse plugin.
Regards,
-marc
On 05.04.16 17:31, Seamus Reynolds wrote:
Hey Mark, thanks for the response! That makes sense - I knew that was
the case for Java, and it follows that it's the case for JaCoCo. One
thing I'm curious about then, (and the answer may be separate from
JaCoCo), is how it seems some reports are getting generated with pages
that show only certain (top-level) packages, rather than all the
packages at once.
For instance, if you look at JaCoCo's own code coverage statistics on
itself:
<https://lh3.googleusercontent.com/-cHHz5fSenAU/VwPZbMf8KmI/AAAAAAAARdU/6_IG5gjIXewX6-P56UIWwUP9VgBt7iDNQ/s1600/JacocoExampleReport.png>
It's HTML report is generated in such a way that you click down into
the packages under org.jacoco.core, org.jacoco.report, etc. Clicking
in, I can definitely see that org.jacoco.core's coverage is being
calculated based on it's classes, not the packages under it, but I'm
curious as to how they're getting that format. Does that have
something to do with specifying a certain 'root' where code coverage
is looking, or some other configuration option?
On Monday, April 4, 2016 at 1:33:50 AM UTC-4, Marc R. Hoffmann wrote:
Hi Seamus,
Java has no notion of "package hierarchies". All packages are
separates, even if they share a common name prefix. The same
applies for JaCoCo reports: As you notices coverage figures are
for a package are based on all classes whithin this package only.
Classes from other packages are not considered.
Regards,
-marc
On 01.04.16 18:18, Seamus Reynolds wrote:
Hey folks,
So I've been running Jacoco on a project for a few months now,
(via the Gradle plugin), and have generally been rather happy
with it.
However, I recently did a big refactor of a high-level package in
my project, and I noticed that Jacoco no longer seems to be
grouping/structuring package hierarchies correctly. Or, to put it
another way, a package's code coverage statistics seem to be
based purely on the classes directly under it, and not the
classes that are an additional package level down.
Example:
* com.example.api - Code Coverage 80%
o Class1 - Code Coverage 100%
o Class2 - Code Coverage 60%
o com.example.api.server - Code Coverage 40%
+ ServerClass1 - Code Coverage 100%
+ ServerClass2 - Code Coverage 0%
+ ServerClass3 - Code Coverage 20%
So, the code coverage for *'com.example.api'* is listing as 80%,
which seems to only be based on the classes directly in
'com.example.api'. It's not considering the classes in the
subpackage *'com.example.api.server'* when calculating the total
coverage for the *'com.example.api'* package. This appears to be
happening for all of my packages, regardless of their place in
the overall package structure.
From what I can tell, this isn't related to the report
generation, but rather based on the resulting exec files
themselves. (I'm basing that on seeing the same results in both a
report from Jenkin's based on the exec data, and the html report
generated by the Gradle JacocoTestReport task).
The html report winds up looking something like this
<https://lh3.googleusercontent.com/-SIeJ1RI4EAs/Vv6eMUAs-1I/AAAAAAAARXM/E0fdEAoyxEscwUh_XyX1LTUdlT6pH5RaA/s1600/JacocoReport.png>
Rather than with packages grouped under each other, like this:
<https://lh3.googleusercontent.com/-9-LJDgZ_BRY/Vv6ehXt_AXI/AAAAAAAARXQ/xr3zWxwnRfoLBWzMuNvYhOTOicT0c9VMw/s1600/JacocoExampleReport.png>
A few hours of googling around, looking at the Jacoco site,
searching the discussions here and on GitHub haven't seemed to
return a reference to this particular problem. Does anyone have
any thoughts or suggestions?
Here's my configuration for Jacoco in Gradle, which is what's
orchestrating the execution of a Jacoco ant task in the
background, generating the .exec file.
jacoco {
toolVersion ="0.7.6.201602180812"
}
jacocoTestReport{
//Test targeting configured here
classDirectories = files(sourceSets.main.allJava.srcDirs)
reports {
csv.enabledfalse
xml.destination"${buildDir}/reports/jacoco/xml"
html.destination"${buildDir}/reports/jacoco/html"
}
executionData = files('build/jacoco/test.exec')
doLast {
//Prints a clickable link in the terminal, if your terminal
emulator supports that
println"*** JaCoCo
Report:file://${buildDir}/reports/jacoco/html/index.html ***"
}
}
--
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 [email protected] <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/ac248218-a25a-4a94-b5b8-9d4c710486a8%40googlegroups.com
<https://groups.google.com/d/msgid/jacoco/ac248218-a25a-4a94-b5b8-9d4c710486a8%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
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 [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/c3bbbf7d-1c8f-42a4-8a9d-34adb4c87392%40googlegroups.com
<https://groups.google.com/d/msgid/jacoco/c3bbbf7d-1c8f-42a4-8a9d-34adb4c87392%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jacoco/570422DF.5080509%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.