I am trying to use the jacoco plugin and somehow setup the build so that when I run the unit tests the classes are already instrumented when powermock goes to do its thing, otherwise powermock instruments the classes and jacoco cannot find any of them because they no longer match, so all classes show 0% coverage.
It seems like this must be possible but cannot find a working example.
2 Likes
JaCoCo instruments classes as they get loaded by the JVM. I don’t think it supports instrumenting classes offline.
JaCoCo supports offline instrumentation.
http://www.eclemma.org/jacoco/trunk/doc/offline.html
Maybe the gradle plugin does not, but not sure. It does use the ant stuff under the hood so I figured maybe it does do it but just isn’t documented.
OK, good to know. Then it’s indeed a limitation of Gradle’s JaCoCo plugin.
Not super familiar with gradle yet, more used to maven, but I might be able to extend the plugin to support this since it already uses the ant stuff. If not, then a custom ant based task. It doesn’t look too complicated just reading about how to use ant from gradle.