-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
98 lines (88 loc) · 3.01 KB
/
build.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
88
89
90
91
92
93
94
95
96
97
98
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacocoVersion"
reportsDirectory = file("$buildDir/reports/coverage")
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
/**
* Task that generates JaCoCo (code coverage) report for Unit Tests, and combines the results
* with any coverage reports for the Instrumented Tests, resulting in one unified code coverage
* report.
*
* Works for Java and/or Kotlin projects.
*/
task jacocoCombinedTestReports(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
group = "Verification"
description = "Creates JaCoCo test coverage report for Unit and Instrumented Tests (combined) on the Debug build"
reports {
xml.enabled = true
html.enabled = true
}
// 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"
])
}
android {
compileSdkVersion 30
defaultConfig {
applicationId "caffeinatedandroid.demomergecoverage"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled true
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}