Skip to content

Commit

Permalink
Add instrumentation tests workaround
Browse files Browse the repository at this point in the history
- Enable testCoverage only for instrumentation tests and disable the flag after
- Add the path for the new instrumentation test coverage ec file

Relates to #358
  • Loading branch information
ekigamba committed Sep 6, 2022
1 parent ef13dbe commit 3f45be0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .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
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
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
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'
]))
}
2 changes: 1 addition & 1 deletion utils/build.gradle
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion wrapper/build.gradle
Original file line number Diff line number Diff line change
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'
]))
}

0 comments on commit 3f45be0

Please sign in to comment.