-
Notifications
You must be signed in to change notification settings - Fork 0
/
jacoco.gradle
69 lines (60 loc) · 1.74 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
jacoco {
toolVersion = '0.8.8'
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
// afterEvaluate {
// classDirectories.from = files(classDirectories.files).asFileTree.matching {
// exclude '**/path/to/folder/filename.class'
// }
// }
doFirst {
if (!gradle.taskGraph.hasTask(test)) {
throw new StopExecutionException()
}
}
}
jacocoTestCoverageVerification {
// afterEvaluate {
// classDirectories.from = files(classDirectories.files).asFileTree.matching {
// exclude '**/path/to/folder/filename.class'
// }
// }
violationRules {
rule {
limit {
counter = 'INSTRUCTION'
value = 'TOTALCOUNT'
minimum = 0.0 // Should be 1.0 if full code coverage is required
}
}
rule {
element = 'CLASS'
limit {
counter = 'BRANCH'
value = 'MISSEDCOUNT'
maximum = 100.0 // Should be 0.0 if full code coverage is required
}
}
}
}
task printCoverageReportLink {
onlyIf { jacocoTestCoverageVerification.state.failure }
doLast { println "Code coverage is missing. See report at: file://${buildDir}/reports/jacoco/test/html/index.html" }
}
jacocoTestCoverageVerification.finalizedBy printCoverageReportLink
task verifyCoverage {
dependsOn jacocoTestReport
onlyIf {
gradle.taskGraph.hasTask(test) && gradle.taskGraph.hasTask(jacocoTestReport)
}
}
jacocoTestReport.dependsOn test
test.finalizedBy jacocoTestCoverageVerification, jacocoTestReport
check.dependsOn verifyCoverage
task coverage {
dependsOn test, verifyCoverage
}