forked from sgrekov/AndroidJacocoSample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quality.gradle
70 lines (53 loc) · 1.72 KB
/
quality.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.7.7.201606060606"
}
def fileFilter = [
'com/androidjacoco/sample/**/view/**.*',
'**/R.class', '**/R$*.class', '**/BuildConfig.*',
'**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
task customJacocoTestReport(type: JacocoReport, dependsOn: 'test') {
reports {
html.enabled = true
html.destination = "${buildDir}/reports/jacoco"
}
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")
}
task customJacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn: 'customJacocoTestReport') {
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")
violationRules {
setFailOnViolation(true)
rule {
element = 'PACKAGE'
limit {
value = 'COVEREDRATIO'
counter = 'BRANCH'
minimum = 0.5
}
}
rule {
element = 'PACKAGE'
limit {
value = 'COVEREDRATIO'
counter = 'INSTRUCTION'
minimum = 0.8
}
}
rule {
element = 'PACKAGE'
includes = ['com.androidjacoco.sample.*.presenter']
enabled = true
limit {
counter = 'CLASS'
value = 'MISSEDCOUNT'
maximum = 0
}
}
}
}