-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage.gradle
87 lines (79 loc) · 3.3 KB
/
coverage.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Android Gradle Plugin out of the box only supports code coverage for instrumentation espresso) tests.
// This add support for unit tests as well.
//./gradlew domain:cleanTest domain:test data:cleanTest data:test remote:cleanTest remote:test cache:cleanTestDebugUnitTest cache:testDebugUnitTest presentation:cleanTestDebugUnitTest presentation:testDebugUnitTest ui:cleanTestDebugUnitTest ui:testDebugUnitTest
//
def fileFilter = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
//Butterknife hack for multi-modules poroject
'**/R2.class',
'**/R2$*.class',
'**/*_ViewBinding*.*',
//Dagger 2
'**/*Dagger*Component*.*',
'**/*Module.*',
'**/*Module$*.*',
'**/*MembersInjector*.*',
'**/*_Factory*.*',
'**/*Provide*Factory*.*',
//Autofactory
'**/*Factory.*',
//Classes I intentionally don't want to test
'**/*Activity.*',
'**/App.class',
'**/*Adapter.*',
'**/*ViewHolder*.*',
'**/api/response/*.*',
'**/data/model/*.*',
]
task testCoverageReport(type: JacocoReport) {
group = 'Reporting'
description = "Generate Jacoco coverage reports for the debug build. Only unit tests."
//Make sure that tests from all modules are run before coverage report
dependsOn ":ui:cleanTest"
dependsOn ":presentation:cleanTest"
dependsOn ":cache:cleanTest"
dependsOn ":remote:cleanTest"
dependsOn ":data:cleanTest"
dependsOn ":domain:cleanTest"
dependsOn ":ui:test"
dependsOn ":presentation:test"
dependsOn ":cache:test"
dependsOn ":remote:test"
dependsOn ":data:test"
dependsOn ":domain:test"
classDirectories = files([
fileTree(dir: "$project.rootDir/ui/build/intermediates/javac/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/presentation/build/intermediates/javac/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/cache/build/intermediates/javac/debug", excludes: fileFilter),
fileTree(dir: "$project.rootDir/remote/build/classes/kotlin/main", excludes: fileFilter),
fileTree(dir: "$project.rootDir/data/build/classes/kotlin/main", excludes: fileFilter),
fileTree(dir: "$project.rootDir/domain/build/classes/kotlin/main", excludes: fileFilter),
])
def coverageSourceDirs = [
"$project.rootDir/app/src/main/java",
"$project.rootDir/presentation/src/main/java",
"$project.rootDir/cache/src/main/java",
"$project.rootDir/remote/src/main/java",
"$project.rootDir/data/src/main/java",
"$project.rootDir/domain/src/main/java",
]
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = fileTree(dir: project.rootDir, includes: [
'ui/build/jacoco/testDebugUnitTest.exec',
'presentation/build/jacoco/testDebugUnitTest.exec',
'cache/build/jacoco/testDebugUnitTest.exec',
'remote/build/jacoco/test.exec',
'data/build/jacoco/test.exec',
'domain/build/jacoco/test.exec',
])
reports {
xml.enabled = true
html.enabled = true
}
}