jacoco
Open JaCoCo report in Intellij IDEA
Found the solution. I have installed the coverage plugin and the EclEmma plugin (not sure if this one is really necessary…). Then “Run -> Show Coverage Data…” and pick your Jacoco output file. This file HAS to have the .exec extension, otherwise you can’t select it. That was my problem… Thanks
Unable to get Jacoco to work with Powermockito using offline instrumentation
This pom worked for me: <build> <finalName>final-name</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <systemPropertyVariables> <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile> </systemPropertyVariables> </configuration> </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.2.201409121644</version> <executions> <execution> <id>default-instrument</id> <goals> <goal>instrument</goal> </goals> </execution> <execution> <id>default-restore-instrumented-classes</id> <goals> <goal>restore-instrumented-classes</goal> </goals> </execution> <execution> <id>default-report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </build> See this … Read more
Running jacocoReport
The task will only run if coverage data is available. You can make sure of that by also running the test task.
Coverage view shows 0.0% in Intellij when using Jacoco
When you add the class to PowerMockito annotation @PrepareForTest for the test classes, the corresponding class will not be showing the code coverage.
JaCoCo Can’t add different class with same name: org/hamcrest/BaseDescription
There are two ways to avoid this: 1)Rename one of the duplicates: I’ve seen this problem quite often when it comes to maven projects. Even if those two classes are in two different modules, having same names for two different classes is not really a good idea. 2)Exclude one of them: Refer this SO thread … Read more
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