Hello, I have been trying to get Jacoco to work with the maven build, because we used sonarqube to as part of our process and we need code coverage metrics. However, no matter what I do, Jacoco is always analyzing zero classes. Is there anything we can do for this? asked 09.01.2020 at 08:27 TareqK |
Updates on this : Got it to work, turns out as @Reguel said, the JDT compiler wont play with a javaagent. I got around this by using the offline mode of jacoco, and copying the generated classes from the classes directory in the correct target/classes and target/test-classes directories . This is what the pom section looks like : You also need to set the <testoutputdirectory> as well, otherwise it wont work The reports are generated in the target/site/jacoco folder, and the jacoco.exec file is in the target folder as well answered 13.01.2020 at 10:07 TareqK Cool solution: thanks for sharing! One remark though:
(13.01.2020 at 10:18)
Reguel Werme... ♦♦
|
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 09.01.2020 at 08:27
Seen: 1,601 times
Last updated: 13.01.2020 at 10:29
Hi
Seems to be an maven configuration problem to me... How do you configure you're maven build? Do you use the jacoco-maven-plugin? Did the tests run? Which JUnit version? Maybe this blog post can help you: https://www.mkyong.com/maven/maven-jacoco-code-coverage-example/
Kind regards
Lukas
I Did indeed do the maven setup, im using maven 4.12 with powermock and mockito, and all the test do run. I checked this configuration compared to the examples on baeldug and mkyong, but still no luck. Jacoco does see all the packages, its just ignoring every class in them.
you may have to set explicitly the test releated vars in pom.xml: e.g.
if that doesn't help: the issue is very likely that jacoco works with a javaagent. Since we setup a custom JDT compiler run, this agent may can not be made known with a standard approach.
However, we can provide detailed feedback if you share a simple project that shows the issue and file it as official support request.