jacoco : Cannot exclude classes

Property excludes of report goal specifies which files should be excluded from analysis during generation of report. In case of /path/tp/my/project/target/classes/META-INF/bundled-dependencies/some-third-party-1-jar-with-dependencies.jar@org/slf4j/event/EventConstants.class file is /path/tp/my/project/target/classes/META-INF/bundled-dependencies/some-third-party-1-jar-with-dependencies.jar , and the rest is about class in JAR file. Therefore as one of examples of correct configuration: <configuration> <excludes> <exclude>META-INF/**</exclude> </excludes> </configuration> As a proof having pom.xml <?xml version=”1.0″ encoding=”UTF-8″?> … Read more

JaCoCo returning 0% Coverage with Kotlin and Android 3.0

You can get line-by-line coverage for both Java and Kotlin code by defining the two different directories for generated .class files: def debugTree = fileTree(dir: “${buildDir}/intermediates/classes/debug”, excludes: fileFilter) def kotlinDebugTree = fileTree(dir: “${buildDir}/tmp/kotlin-classes/debug”, excludes: fileFilter) Then, simply include both fileTrees in your classDirectories: classDirectories.from = files([debugTree], [kotlinDebugTree])

jacoco code coverage report generator showing error : “Classes in bundle ‘Code Coverage Report’ do no match with execution data”

You are getting the error related to classID. This is a concept described in detail at JaCoCo docs-site. http://www.eclemma.org/jacoco/trunk/doc/classids.html. This is a key step for supporting multiple versions of class (an appserver for example) in same JVM. Copying part some part of it here for visibility. What are class ids and how are they created? … Read more

How would I add an annotation to exclude a method from a jacoco code coverage report?

Since there are no direct answers to this, did a bit of research and came across this PR. https://github.com/jacoco/jacoco/pull/822/files private static boolean matches(final String annotation) { final String name = annotation .substring(Math.max(annotation.lastIndexOf(“https://stackoverflow.com/”), annotation.lastIndexOf(‘$’)) + 1); return name.contains(“Generated”) } You can create any annotation with name containing “Generated”. I’ve created the following in my codebase to … Read more

Getting “Skipping JaCoCo execution due to missing execution data file” upon executing JaCoCo

jacoco-maven-plugin:0.7.10-SNAPSHOT From jacoco:prepare-agent that says: One of the ways to do this in case of maven-surefire-plugin – is to use syntax for late property evaluation: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>@{argLine} -your -extra -arguments</argLine> </configuration> </plugin> Note the @{argLine} that’s added to -your -extra -arguments. Thanks Slava Semushin for noticing the change and reporting in the … Read more

integrating JaCoCo in sonar using Ant

The following is an ANT build that is configured to run a junit unit test and use jacoco for code coverage reporting. The results are uploaded to Sonar and finally ivy is used to download 3rd party jars and manage classpaths. Example ├── build.properties ├── build.xml ├── ivy.xml └── src ├── main │   └── java … Read more

Android test code coverage with JaCoCo Gradle plugin

Here is how I’m using Jacoco: buildscript { repositories { mavenLocal() mavenCentral() } dependencies { classpath ‘com.android.tools.build:gradle:0.12.+’ classpath ‘org.robolectric:robolectric-gradle-plugin:0.11.+’ } } apply plugin: ‘com.android.application’ apply plugin: ‘robolectric’ apply plugin: ‘jacoco’ android { compileSdkVersion 20 buildToolsVersion “20.0.0” defaultConfig { applicationId “YOUR_PACKAGE_NAME” minSdkVersion 10 targetSdkVersion 20 testHandleProfiling true testFunctionalTest true } buildTypes { debug { testCoverageEnabled false … Read more

Cannot use jacoco JVM args and surefire JVM args together in maven

Try using @{argLine} instead of ${argLine} (or surefire.argLine in your case) It allows surefire to read a property as modified by other plugins instead of reading the one substituted by Maven itself. Then you can set the argLine param to empty in Maven properties: <properties> <argLine></argLine> </properties> Which now will not cause any problems. More … 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

Maven Jacoco Configuration – Exclude classes/packages from report not working

Your XML is slightly wrong, you need to add any class exclusions within an excludes parent field, so your above configuration should look like the following as per the Jacoco docs <configuration> <excludes> <exclude>**/*Config.*</exclude> <exclude>**/*Dev.*</exclude> </excludes> </configuration> The values of the exclude fields should be class paths (not package names) of the compiled classes relative … Read more