PR#143 Fix tests can't run on API 21

Seems like jacoco androidTestCoverage breaks tests on API 21 with Resource.NotFound for some reason.
It works well on newer API levels.
To workaround it, we simply disable that coverage for CI.
This commit is contained in:
Gergely Hegedus 2023-01-18 15:33:12 +02:00
parent 49b7b630f0
commit a37c6a4a3d
3 changed files with 7 additions and 4 deletions

View file

@ -122,7 +122,7 @@ jobs:
force-avd-creation: false force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true disable-animations: true
script: ./gradlew connectedDebugAndroidTest script: ./gradlew connectedDebugAndroidTest -PdisableAndroidTestCoverage=true
- name: Upload Test Results - name: Upload Test Results
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: always() if: always()

View file

@ -256,7 +256,8 @@ To see an aggregated code coverage report:
- task `runTestAndJacocoRootReport` will run all the sub modules reports and tests then run `jacocoRootReport`. - task `runTestAndJacocoRootReport` will run all the sub modules reports and tests then run `jacocoRootReport`.
### Issues ### Issues
*One issue, is that the androidTest reports don't work with the sharedTest module setup, this issue is reported [here](https://issuetracker.google.com/issues/250130118)* - One issue, is that the androidTest reports don't work with the sharedTest module setup, this issue is reported [here](https://issuetracker.google.com/issues/250130118)
- Another issue, is that seems like the tests fail with Resource.NotFound on API 21 if `enableAndroidTestCoverage` is true, so I disabled that for CI.
By shared test module setup I mean a module like `app-shared-test`, which has a dependency graph of: By shared test module setup I mean a module like `app-shared-test`, which has a dependency graph of:
- app-shared-test -> app.main - app-shared-test -> app.main

View file

@ -64,8 +64,10 @@ def setupAndroidJacoco(Project module, ArrayList<String> fileFilter, String jaco
jacoco.includeNoLocationClasses = true jacoco.includeNoLocationClasses = true
jacoco.excludes = fileFilter jacoco.excludes = fileFilter
} }
android.buildTypes.debug.enableAndroidTestCoverage true // on API 21 enableAndroidTestCoverage makes the tests crash with resource not found issue
android.buildTypes.debug.enableUnitTestCoverage true def disableAndroidTestCoverage = findProperty("disableAndroidTestCoverage") ?: false
android.buildTypes.debug.enableAndroidTestCoverage = !disableAndroidTestCoverage
android.buildTypes.debug.enableUnitTestCoverage = true
jacoco.toolVersion = "$jacocoVersion" jacoco.toolVersion = "$jacocoVersion"