Running jacocoReport
The task will only run if coverage data is available. You can make sure of that by also running the test task.
The task will only run if coverage data is available. You can make sure of that by also running the test task.
When you add the class to PowerMockito annotation @PrepareForTest for the test classes, the corresponding class will not be showing the code coverage.
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
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
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
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
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
Any particular reason why you are using an outdated version of the JaCoCo plugin? For Java 8 support, you have to use at least version 0.7.0 (see changelog). In your configuration, the report goal is bound to the verify phase, so running mvn test won’t generate any report because it does not run the verify … Read more