Skip to content

Commit 42961f2

Browse files
committed
test(android, jacoco): configure app and modules for offline coverage instrumentation
the resources file is a special trick so the jacoco offline agent does not crash jacoco/jacoco#968
1 parent 2307cd3 commit 42961f2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

tests/android/app/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ android {
7474
}
7575

7676
buildTypes {
77+
debug {
78+
debuggable true
79+
testCoverageEnabled true
80+
}
7781
release {
7882
minifyEnabled true
7983
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
@@ -82,6 +86,12 @@ android {
8286
}
8387
}
8488

89+
testOptions {
90+
unitTests {
91+
includeAndroidResources = true
92+
}
93+
}
94+
8595
compileOptions {
8696
sourceCompatibility 1.8
8797
targetCompatibility 1.8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output=none

tests/android/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,17 @@ subprojects {
8080
}
8181
}
8282
}
83-
if (project.name.contains('firebase')
83+
84+
// Configure testing settings - if set in module build.gradle files they affect library consumers
85+
if (project.name.contains("react-native-firebase")
8486
&& project.hasProperty('android')) {
8587
android {
88+
// Instrument all our modules for coverage generation
89+
buildTypes.debug.testCoverageEnabled true
90+
jacoco.version '0.8.7'
91+
testOptions.unitTests.includeAndroidResources = true
92+
93+
// Make sure our project are run through basic lint checks
8694
lintOptions {
8795
abortOnError = true
8896
warningsAsErrors false

0 commit comments

Comments
 (0)