Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instrumentation tests coverage workaround #360

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ jobs:
run: ./gradlew clean --stacktrace
- name: Build project skipping tests
run: ./gradlew build -x test --stacktrace
- name: Enable test coverage for all modules for instrumentation tests
run: sed -i '' 's/testCoverageEnabled false/testCoverageEnabled true/g' library/build.gradle && sed -i '' 's/testCoverageEnabled false/testCoverageEnabled true/g' utils/build.gradle && sed -i '' 's/testCoverageEnabled false/testCoverageEnabled true/g' sample/build.gradle && sed -i '' 's/testCoverageEnabled false/testCoverageEnabled true/g' wrapper/build.gradle
- name: Run Instrumented Tests manually
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 22
api-level: 24
script: ./gradlew connectedDebug --stacktrace
- name: Disable test coverage for all modules
run: sed -i '' 's/testCoverageEnabled true/testCoverageEnabled false/g' library/build.gradle && sed -i '' 's/testCoverageEnabled true/testCoverageEnabled false/g' utils/build.gradle && sed -i '' 's/testCoverageEnabled true/testCoverageEnabled false/g' sample/build.gradle && sed -i '' 's/testCoverageEnabled true/testCoverageEnabled false/g' wrapper/build.gradle
- name: Run jacocoTestReport for each module
run: ./gradlew jacocoTestReport --stacktrace --info
- name: Merge jacoco reports from all modules
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ This is encountered when Robolectric has problems downloading the jars it needs

```
./download-robolectric-deps.sh
```

## License

Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ android {

debug {
// See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183
testCoverageEnabled false
testCoverageEnabled true

if (project.rootProject.file("local.properties").exists()) {
Properties properties = new Properties()
Expand Down Expand Up @@ -200,7 +200,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //
sourceDirectories.setFrom([mainSrc])
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec', 'outputs/code_coverage/**/connected/**/*coverage.ec'
]))
}

Expand Down
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {

debug {
// See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183
testCoverageEnabled false
testCoverageEnabled true
buildConfigField "String", "MAPBOX_SDK_ACCESS_TOKEN", localProperties["mapbox.sdk.token"]
buildConfigField "String", "CGR_USERNAME", localProperties["cgr.username"]
buildConfigField "String", "CGR_PASSWORD", localProperties["cgr.password"]
Expand Down Expand Up @@ -163,6 +163,6 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec', 'outputs/code_coverage/**/connected/**/*coverage.ec'
]))
}
4 changes: 2 additions & 2 deletions utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {

debug {
// See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183
testCoverageEnabled false
testCoverageEnabled true
}
}

Expand Down Expand Up @@ -92,7 +92,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec', 'outputs/code_coverage/**/connected/**/*coverage.ec'
]))
}

Expand Down
4 changes: 2 additions & 2 deletions wrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

debug {
// See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183
testCoverageEnabled false
testCoverageEnabled true
}
}

Expand Down Expand Up @@ -82,6 +82,6 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) { //
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([debugTree]))
executionData.setFrom(fileTree(dir: project.buildDir, includes: [
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec', 'outputs/code_coverage/**/connected/**/*coverage.ec'
]))
}