5

I already read some articules related to this, this and this but I could not found the answer. Using the Gradle Plugin in Android Studio, I can't generate the file jacoco.exec (neither *.exec in any subfolder).

What do I have to set in the build.gradle file in order to generate this file?

Note: Remember that I'm using the Gradle Plugin (which is different) and Android Studio.

Community
  • 1
  • 1
Juan Saravia
  • 7,661
  • 6
  • 29
  • 41

1 Answers1

5

By default Gradle connectedInstrumentTest task generates test reports in .ec format (Emma). If you need jacoco.exec report file you need Robolectric + JUnit tests instead of Android unit tests (based on InstrumentationTestCase). Here is an example of JaCoCo Gradle plugin configuration.

Veaceslav Gaidarji
  • 4,261
  • 3
  • 38
  • 61
  • Just wanted to add that you should ensure you're debug project has the 'testCoverageEnabled true' setting, and jacoco coverage will be generated like magic. – Billy Lazzaro Feb 23 '15 at 21:53
  • 2
    If you add "testCoverageEnabled true" and use InstrumentationTestCase without Robolectric, then you will get just jacoco.ec coverage file and not jacoco.exec. It's a main point. Of course you will see jacoco reports (html, xml) in build folder. But, such systems as Sonar, doesn't support .ec reports, they need .exec file :( – Veaceslav Gaidarji Feb 24 '15 at 08:08