【问题标题】:GitHub Actions run Espresso testsGitHub Actions 运行 Espresso 测试
【发布时间】:2021-07-09 20:10:24
【问题描述】:

我目前正在尝试使用 GitHub Actions 让我的 Instrumentation tests 运行。我的单元测试运行良好,但似乎无法运行 Espresso 测试。我目前正在尝试:

    - name: Run Instrumentation Tests (reactivecircus)
    uses: reactivecircus/android-emulator-runner@v2.6.1
    with:
      api-level: 23
      target: default
      arch: x86
      profile: Nexus 6
      script: ./gradlew connectedCheck --stacktrace

我得到了结果:

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

当我使用时:

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

我明白了

/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

如果你想看到我所有的尝试,你可以看到所有的提交on my pull request

【问题讨论】:

  • 我在使用 reactivecircus/android-emulator-runner@v2./gradlew connectedCheck 脚本创建 github 操作时没有遇到任何问题,该项目具有 Espresso UI 测试,即使使用 your emulator settings api-level: 23 ...。你可以在这里查看Android Espresso Test CI / test。在本地运行时测试是否通过?
  • 是的,测试在本地通过 - 我会看看你的
  • 当然,如果我的测试在 lib 失败的地方应该报告呢?这只是事后的想法。很高兴有一个使用这些东西的项目我可以看看 - 谢谢
  • 我发现了问题。在本地,您很可能有一个比API 23 android 版本更新的模拟器。在 github 操作上,您正在使用 API 23 运行模拟器,并且在您的项目内部有一个 app/src/main/res/drawable-v24 内部资源,因此它不适用于具有 < 24 API 版本的模拟器。将目录重命名为drawable-v23 后,我尝试运行测试;它可以找到资源,但在旧 API 版本上运行 espresso 似乎存在更多问题。如果可以将模拟器 API 版本更改为兼容的 espresso 版本,我可以提供答案。
  • 因为我想在我的 min sdk 上运行 espresso 测试,所以我选择了 23。我尝试将它升级到 v24,但还有其他问题,我仍然需要修复测试

标签: continuous-integration android-espresso github-actions


【解决方案1】:

您在本地运行的模拟器版本,它很可能比API 23 android 版本更新。在github actions script 上,您正在使用API 23 运行模拟器:

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

并且在您的项目内部有一个app/src/main/res/drawable-v24 内部资源,因此它不适用于< 24 API 版本的模拟器。您要么必须将该目录更改为 drawable-v23,要么将资源移动到旧版本可以访问的另一个 drawable

即使您将可绘制目录更改为drawable-v23,Espresso 也可能存在问题。您要么必须解决该版本,要么必须为您的 GitHub 操作模拟器使用更新的 API 版本,可能与您在开发环境中使用的相同。

【讨论】:

    猜你喜欢
    • 2021-06-25
    • 2021-03-20
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2022-07-26
    • 2021-11-15
    • 1970-01-01
    相关资源
    最近更新 更多