Can't get Jacoco coverage to work with app in container
See original GitHub issueThis isn’t a bug, but a question. Please remove if this isn’t the place.
Background
I am running a Dropwizard app (using java -jar myjar.jar server config.yml
) inside a docker container via this plugin, and I’m running integration tests inside it. In my integration test, I know for sure that code is being exercised, but Jacoco coverage reports for the integration tests aren’t showing coverage.
My Questions
How do I know that Jacoco is properly attached to the code running inside the container? Do I have to do anything special to extract the coverage report from the running container? I would think that a simple shared volume would work, as I am using now, but that does not seem to be the case. I have a hunch that I need to add the jacoco agent parameters to the java -jar
that’s taking place inside my container, but I’m not sure.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6
Top GitHub Comments
@rhuss
Thanks for the tip - that worked splendidly!
Here’s what I ended up doing:
-P integration-tests
Thanks again!
To anyone who comes across this issue via Googling for answers: If you are running your Dropwizard integration tests inside a Docker container, you will need to alter your java jar run command to include a properly-configured -javaagent parameter (see http://www.eclemma.org/jacoco/trunk/doc/agent.html). After you do this, you will be able to use a jacoco report step to load the .exec file and convert it to HTML output.
One more note for pilgrims coming from search engines:
Sometimes, files created inside a shared volume end up being owned by root on the host box. If you run into this, then I recommend doing the following: