You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rolf Smit edited this page Nov 9, 2023
·
1 revision
If the default plugin configuration does not work for your use-case or you just want to tweak the default behavior you can add the rootCoverage configuration block to your root build.gradle file. The rootCoverage block allows you to tweak certain settings, like whether or not JaCoCo should generate an HTML report, just a CSV file, or maybe even an XML file.
build.gradle (root)
// rootCoverage usually sits somewhere at the bottom of this file,// on top you would usually have your plugins Gradle block
rootCoverage {
excludes = ["**/MustBeExcluded.class"]
generateHtml true
generateXml false
generateCsv true
buildVariant "debug"
executeUnitTests true
includeUnitTestResults true
executeAndroidTests false
includeAndroidTestResults false
}
Options
The following is a table of all the possible configuration options, in which version of the plugin they have been introduced and what the default value is. Some options are explained in a bit more detail below the table.
Name
Since
Default value
buildVariant
n.a.
"debug"
buildVariantOverrides
n.a.
emptyMap()
excludes
n.a.
emptyList()
generateCsv
1.1
false
generateHtml
1.1
true
generateXml
1.1
false
executeAndroidTests
1.2
true
executeUnitTests
1.2
true
includeAndroidTestResults
1.2
true
includeUnitTestResults
1.2
true
includeNoLocationClasses
1.4
false
runOnGradleManagedDevices
1.7
false
gradleManagedDeviceName
1.7
null
excludes
Excludes allows filtering certain classes out of the code coverage report.
There are some exclude patterns hardcoded into the plugin that you cannot currently remove:
We need to rethink the usage of these hardcoded excludes as some patterns are way too generic, so
this may change in the future.
gradleManagedDeviceName
Allows setting a specific Gradle Managed Device as the device that will be used for code coverage,
defaults to null in which case the plugin will run tests on all devices (or any device available).