JaCoCo Android Coverage with Ant

Viewed 1119

I have been working on a project that I want to start using JaCoCo. I was wondering if you could help me with an issue I have been having. The project is using Ant to automate building & testing and has an Android component. I have been trying to integrate JaCoCo coverage reports into the project, but have not made much progress when it comes to Android.

Unfortunately, the documentation for the Ant tasks are not all that detailed and the off-line example is only the most basic case. I found examples of how to use Maven, but nothing for Ant. I found vague references to the fact that JaCoCO on Android does work, but not explanation of how it all works.

I was able to do the off-line instrumentation by putting that task in a -post-compile target the custom_rule.xml file within the Android project folder. However, I'm not sure about how to properly configure the java agent to run and retrieve the .exec file to use for generating a report.

  • Should the java agent be in the libs directory of the main project or the test project?
  • Should I be putting a jacoco-agent.properties in the project's libs folder? Or is there a better way to configure the agent?
  • What is the easiest way to write the output to a file on the host computer? Is a TCP connection better than dumping to a file on the device that could then be copied off of the emulator?
1 Answers
Related