Discussion:
[java code coverage] Jacoco with Bazel and Jenkins
m***@gmail.com
2016-01-22 01:04:46 UTC
Permalink
Hello,

I am trying to add code coverage to a Bazel project which, as far as I can tell, is not yet supported inherently. To complicate things further, I'm not much of an expert with Jacoco. I am generating a jacoco.exec file, but how can I tell if it is valid?

Here is what I've got working:

This entry in my BUILD file for Bazel does generate a jacoco.exe file:
---------------------------------------------------
java_test(
name = "lock_coverage",
size = "small",
runtime_deps = [
"//java/com/shn/base/io/lock:lock",
"//thirdparty:hamcrest-core",
"//thirdparty:junit",
],
jvm_flags = ["-javaagent:/shn/builder/workspace/build-io-lock/EngProd/buildtools/jacocoagent.jar=destfile=/shn/builder/workspace/build-io-lock/bazel-genfiles/jacoco.exec"]
)
---------------------------------------------------
The relevant line is the one at the end that defines the jvm flags for jacoco.

I've been counting on the Jenkins Jacoco plugin to present a code coverage report for me but the report looks empty. It might be that I've just configured the plugin incorrectly in the job. But it would be nice to have some quick and easy way to validate the jacoco.exec file outside of Bazel and Jenkins so I know where to focus my debugging effort.

(I see an Ant way to generate a report, but I don't have any confidence that I'd have that configured correctly either. Is there some direct way to tell that a jacoco.exec is "good".)
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/97622e6d-5817-4031-9046-54dde414c6ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marc Hoffmann
2016-01-22 09:43:23 UTC
Permalink
Post by m***@gmail.com
Is there some direct way to tell that a jacoco.exec is "good"
JaCoCo doesn't come with an out-of-the-box tool to inspect exec files.
But we provide a small Java snippet to look into exec files:

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

Regards,
-marc
Post by m***@gmail.com
Hello,
I am trying to add code coverage to a Bazel project which, as far as I
can tell, is not yet supported inherently. To complicate things
further, I'm not much of an expert with Jacoco. I am generating a
jacoco.exec file, but how can I tell if it is valid?
---------------------------------------------------
java_test(
name = "lock_coverage",
size = "small",
runtime_deps = [
"//java/com/shn/base/io/lock:lock",
"//thirdparty:hamcrest-core",
"//thirdparty:junit",
],
jvm_flags =
["-javaagent:/shn/builder/workspace/build-io-lock/EngProd/buildtools/jacocoagent.jar=destfile=/shn/builder/workspace/build-io-lock/bazel-genfiles/jacoco.exec"]
)
---------------------------------------------------
The relevant line is the one at the end that defines the jvm flags for jacoco.
I've been counting on the Jenkins Jacoco plugin to present a code
coverage report for me but the report looks empty. It might be that
I've just configured the plugin incorrectly in the job. But it would
be nice to have some quick and easy way to validate the jacoco.exec
file outside of Bazel and Jenkins so I know where to focus my
debugging effort.
(I see an Ant way to generate a report, but I don't have any
confidence that I'd have that configured correctly either. Is there
some direct way to tell that a jacoco.exec is "good".)
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/091cc54b4281d0447932caff3b0dbf2f%40mountainminds.com.
For more options, visit https://groups.google.com/d/optout.
Loading...