Problem:
I have a project with jacoco and I want to be able to filter certain classes and/or packages.
Related Documentation:
I have read the following documentation:
Official jacoco site: http://www.eclemma.org/jacoco/index.html
Official jacoco docs for gradle: https://gradle.org/docs/current/userguide/jacoco_plugin.html
Official jacoco Github
issues, working on coverage:
https://github.com/jacoco/jacoco/wiki/FilteringOptions
https://github.com/jacoco/jacoco/issues/14
Related StackOverflow Links:
JaCoCo & Gradle - Filtering Options (No answer)
Exclude packages from Jacoco report using Sonarrunner and Gradle (Not using sonar)
JaCoCo - exclude JSP from report (It seems to work for maven, I am using gradle)
Maven Jacoco Configuration - Exclude classes/packages from report not working (It seems to work for maven, I am using gradle)
JaCoCo gradle plugin exclude (Could not get this to work)
Gradle Jacoco - coverage reports includes classes excluded in configuration (Seems very close, it used doFirst
, did not work for me)
Example of what I have tried:
apply plugin: 'java'
apply plugin: 'jacoco'
buildscript {
repositories {
mavenCentral()
jcenter()
}
}
repositories {
jcenter()
}
jacocoTestReport {
reports {
xml {
enabled true // coveralls plugin depends on xml format report
}
html {
enabled true
}
}
test {
jacoco {
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
excludes = ["projecteuler/**"] // <-- does not work
// excludes = ["projecteuler"]
}
}
}
Question:
How can I exclude certain packages and classes when generating the jacoco coverage reports?
packages
online usingCodecov
? Also, I saw theGithub
, what aboutAndroid
support, I sawJava
. I should still have to send you all of the reports then filter after vs filtering before. – Jared Burrowsexcludes
from the official documentation actually do then? Is it pretty much useless? – Vivin Paliathexcludes
is not on the coverage task, but on the test task. It excludes files from being instrumented by JaCoCo and thus coverage being recorded. You can use this if you don't want to record coverage for some classes, if you cannot because of some conflict with another instrumenting agent, or because you pre-instrumented classes. This will not exclude a class from the report, especially in the last case mentioned, this would be a horrible idea. – Vampire