【发布时间】: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 settingsapi-level: 23 ...。你可以在这里查看Android Espresso Test CI / test。在本地运行时测试是否通过? -
是的,测试在本地通过 - 我会看看你的
-
当然,如果我的测试在 lib 失败的地方应该报告呢?这只是事后的想法。很高兴有一个使用这些东西的项目我可以看看 - 谢谢
-
我发现了问题。在本地,您很可能有一个比
API 23android 版本更新的模拟器。在 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