-
Notifications
You must be signed in to change notification settings - Fork 10
/
jacoco.gradle
70 lines (61 loc) · 2.05 KB
/
jacoco.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
apply plugin: "jacoco"
jacoco {
toolVersion = "0.8.7"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
// Files with such regex patterns are to be excluded
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*',
'**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
// Location of generated output classes
def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug",
excludes: fileFilter)
// Source code directory
def mainSrc = "$project.projectDir/src/main/java"
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.required = true
html.required = true
}
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: "$buildDir", includes: [
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec",
"outputs/code_coverage/debugAndroidTest/connected/**/*coverage.ec"
]))
}
task verifyTestCoverage(type: JacocoCoverageVerification) {
enabled = true
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([debugTree])
executionData.setFrom(fileTree(dir: "$buildDir", includes: [
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec",
"outputs/code_coverage/debugAndroidTest/connected/**/*coverage.ec"
]))
violationRules {
failOnViolation = true
// 1
rule {
enabled = true
element = 'PACKAGE'
includes = ['com.tealium.*']
limit {
counter = 'CLASS'
value = 'MISSEDCOUNT'
maximum = 1
}
}
// 2
rule {
element = 'PACKAGE'
includes = ['com.tealium.*']
limit {
value = 'COVEREDRATIO'
counter = 'INSTRUCTION'
minimum = 0.3
}
}
}
}