3
votes

I am currently trying to get my Instrumentation tests to run using GitHub Actions. I have the unit tests running fine but I cannot seem to get the Espresso tests to run. I am currently trying:

    - name: Run Instrumentation Tests (reactivecircus)
    uses: reactivecircus/[email protected]
    with:
      api-level: 23
      target: default
      arch: x86
      profile: Nexus 6
      script: ./gradlew connectedCheck --stacktrace

And I get the result:

com.balsdon.ratesapp.behaviour.RateListActivityEntryBehaviourInstrumentedTest > recyclerViewClickOnItemChangesMain[test(AVD) - 6.0] FAILED 
    android.content.res.Resources$NotFoundException: Resource ID #0x7f0700d3
    at android.content.res.Resources.getValue(Resources.java:1351)
Tests on test(AVD) - 6.0 failed: Instrumentation run failed due to 'android.content.res.Resources$NotFoundException'

> Task :app:connectedOfflinemockDebugAndroidTest FAILED
> Task :app:processOnlineecbDebugAndroidTestResources
> Task :app:processProductionDebugAndroidTestResources

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedOfflinemockDebugAndroidTest'.
> There were failing tests. See the report at: file:///Users/runner/runners/2.165.2/work/currency_list_app/currency_list_app/app/build/reports/androidTests/connected/flavors/OFFLINEMOCK/index.html

and when I use:

    - uses: malinskiy/action-android/emulator-run-cmd@release/0.0.5
    with:
      cmd: ./gradlew integrationTest
      api: 23
      tag: default
      abi: x86

I get

/Users/runner/android-sdk/platform-tools/adb -s emulator-5554 shell getprop sys.boot_completed
error: device 'emulator-5554' not found
The process '/Users/runner/android-sdk/platform-tools/adb' failed with exit code 1

If you want to see all my attempts, you can see all the commits on my pull request

1
I didn't have any trouble creating a github action using reactivecircus/android-emulator-runner@v2 with ./gradlew connectedCheck script on a project having Espresso UI testing even with your emulator settings api-level: 23 .... You can check it out here Android Espresso Test CI / test. Are the tests pass when running locally? - Christos Lytras
Yep the tests pass locally - I'll take a look at yours - Quintin Balsdon
Surely if my tests where failing the lib should report that though? Just an after thought while this is going. So glad there is a project using this stuff I can look at though - thank you - Quintin Balsdon
I found the issue. Locally, you most likely have an emulator with a newer than API 23 android version. On github actions you're running the emulator using API 23 and inside your project there is a app/src/main/res/drawable-v24 inside resources, thus it wont be available for emulators with < 24 API version. I've tried to run the test after renaming the directory to drawable-v23; it can find the resources but there seems to be more issues running espresso on older API versions. If it's fine to change the emulator API version to a compatible espresso version, I can provide an answer. - Christos Lytras
Since I want to espresso tests to run on my min sdk, I went with 23. I tried bumping it to v24, but there were other issues and I needed to fix tests anyway - Quintin Balsdon

1 Answers

3
votes

Your emulator version that you run locally, it's most likely newer than API 23 android version. On github actions script you're running the emulator using API 23:

    uses: reactivecircus/android-emulator-runner@v2
    with:
      api-level: 23
      target: default
      arch: x86
      profile: Nexus 6
      script: ./gradlew connectedCheck --stacktrace

and inside your project there is a app/src/main/res/drawable-v24 inside resources, thus it wont be available for emulators with < 24 API version. You either have to change that directory to be drawable-v23 or you move the resources to an other drawable that older versions can access.

Even if you change the drawable directory to drawable-v23, Espresso may have issues. You'll either have to resolve for that version or you'll have to use a newer API version for your GitHub action emulator, maybe the same as you have on your development environment.