Using JaCoCo with Liberty Profile 8.5.5.4 in Eclipse does not produce any code coverage

513 views Asked by At

I am trying to use JaCoCo for code coverage. I am running Liberty from Eclipse (using the Eclipse launcher). In jvm.options, I added these lines: (substitute <location> for a path)

-Xshareclasses:none
-javaagent:<location>/jacocoagent.jar=destfile=jacoco.exec,output=file,append=false,classdumpdir=./classdump

however, after running the tests, I do not see any coverage information. It looks like JaCoCo cannot link to the Java classes that are in my web application war file.

Is there a different process run by liberty that has the java classes? Can a java agent be attached to that process?

2

There are 2 answers

7
Brett Kail On BEST ANSWER

Are you using JaCoCo 0.7.3 or later? If yes, I suspect the problem is caused by changes in issue #272 because last I checked, WebSphere Liberty profile did not define classes with a CodeSource location, so this heuristic in JaCoCo causes all classes in applications running on WebSphere Liberty profile to be ignored. If you can confirm that's the case for your application on some recent Liberty fixpak (MyClass.class.getProtectionDomain().getCodeSource().getLocation()), then I would suggest opening a WebSphere RFE, a JaCoCo issue, or both.

1
Anton On

Problem resolved.

Had to use an older version of JaCoCo (0.7.2) instead of the latest (0.7.6).

Thanks to bkail