Jacoco and Unit Tests Code Coverage with android-gradle-plugin >= 1.1

After the hassle, I decided to create an open source Gradle plugin for that. Root build.gradle buildscript { repositories { mavenCentral() // optional if you have this one already } dependencies { classpath ‘com.vanniktech:gradle-android-junit-jacoco-plugin:0.16.0’ } } apply plugin: ‘com.vanniktech.android.junit.jacoco’ Then simply execute ./gradlew jacocoTestReportDebug It’ll run the JUnit tests in Debug Mode and then give … Read more

Jacoco with Gradle 0.10.0: Remote object doesn’t exist

Try This One… buildscript { repositories { mavenCentral() } dependencies { classpath ‘com.android.tools.build:gradle:0.13.0’ } } repositories { mavenCentral() } apply plugin: ‘com.android.application’ apply plugin: ‘jacoco’ android { compileSdkVersion 21 buildToolsVersion “21.1.1” // Must Require defaultConfig { applicationId “com.packagename” <Change it> minSdkVersion 11 targetSdkVersion 21 versionCode 1 versionName “1.0” } packagingOptions { exclude ‘META-INF/DEPENDENCIES’ exclude ‘META-INF/LICENSE’ … Read more

Merging Integration and Unit test reports with JaCoCo

I recently implemented this: after some headaches and a lot of testing, I have a configuration that works beautifully. <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> <propertyName>surefireArgLine</propertyName> </configuration> </execution> <execution> <id>pre-integration-test</id> <goals> <goal>prepare-agent-integration</goal> </goals> <configuration> <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile> <propertyName>testArgLine</propertyName> </configuration> </execution> <execution> <id>post-integration-test</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile> <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory> </configuration> </execution> … Read more

How do I get a jacoco coverage report using Android gradle plugin 0.10.0 or higher?

Over the hundreds of times searching the answer to getting a coverage report, I finally found an exact answer what I want. From the this blog post, I found that gradlew createDebugCoverageReport creates the jacoco coverage report. Also, from the gradle plugin source code, the plugin uses jacoco 0.6.2.201302030002 by default. (therefore, jacoco version definition … Read more