Created
March 3, 2023 07:58
-
-
Save mfebrianto/65b1056e688467dab3e1ada48a5d8f90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task jacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { | |
group = "Verification" | |
description = "Check code coverage" | |
onlyIf = { | |
true | |
} | |
violationRules { | |
rule { | |
limit { | |
minimum = 0.5 | |
} | |
} | |
rule { | |
enabled = false | |
element = 'CLASS' | |
includes = ['org.gradle.*'] | |
limit { | |
counter = 'LINE' | |
value = 'TOTALCOUNT' | |
maximum = 0.3 | |
} | |
} | |
} | |
// Files to exclude: | |
// Generated classes, platform classes, etc. | |
def excludes = [ | |
'**/R.class', | |
'**/R$*.class', | |
'**/BuildConfig.*', | |
'**/Manifest*.*', | |
'**/*Test*.*', | |
'android/**/*.*' | |
] | |
// generated classes | |
classDirectories.from = fileTree( | |
dir: "$buildDir/intermediates/classes/debug", | |
excludes: excludes | |
) + fileTree( | |
dir: "$buildDir/tmp/kotlin-classes/debug", | |
excludes: excludes | |
) | |
// sources | |
sourceDirectories.from = [ | |
android.sourceSets.main.java.srcDirs, | |
"src/main/kotlin" | |
] | |
// Output and existing data | |
// Combine Unit test and Instrumented test reports | |
executionData.from = fileTree(dir: "$buildDir", includes: [ | |
// Unit tests coverage data | |
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec", | |
// Instrumented tests coverage data | |
"outputs/code_coverage/debugAndroidTest/connected/*coverage.ec" | |
]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment