GitHub 操作 运行 Espresso 测试
GitHub Actions run Espresso tests
我目前正在尝试使用 GitHub 操作让我的 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
您在本地 运行 的模拟器版本,很可能比 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 目录更改为 drawable-v23
,Espresso 也可能会出现问题。您要么必须解决该版本,要么必须为您的 GitHub 动作模拟器使用更新的 API 版本,可能与您在开发环境中使用的相同。
我目前正在尝试使用 GitHub 操作让我的 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
您在本地 运行 的模拟器版本,很可能比 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 目录更改为 drawable-v23
,Espresso 也可能会出现问题。您要么必须解决该版本,要么必须为您的 GitHub 动作模拟器使用更新的 API 版本,可能与您在开发环境中使用的相同。