使用 Detox 测试从 Expo 的 Turtle CLI 构建的 Android .apk

问题描述

我希望在尝试测试使用 Expo's Turtle-CLI 工具构建的 Android 应用程序时确认我的思考过程。我的 iOS 运行良好,只是需要帮助让 Android 正常运行。

我有一个构建过程,可以将 .apk 吐出到 build/android.apk。这是执行此操作的命令

turtle build:android \
       --output $BUILD_DIR/android.apk \
       --username $EXPO_USERNAME \
       --password $EXPO_PASSWORD \
       --config app.config.ts \
       --release-channel $RELEASE_CHANNEL \
       --type apk \
       --mode debug

这成功地输出.apk 中的 build

这是我的 detoxrc.json 配置

{
  "testRunner": "jest","runnerConfig": "e2e/config.json","configurations": {
    "ios": {
      "type": "ios.simulator","binaryPath": "build/app-native.app","build": "./scripts/build_test_app ios","device": {
        "type": "iPhone 11"
      }
    },"android": {
      "type": "android.attached","binaryPath": "build/android.apk","testBinaryPath": "build/android.apk","build": "./scripts/build_test_app android","device": {
        "adbname": "059aaa47"
      }
    }
  }
}

然后我尝试使用

运行我的测试
detox test --configuration android --loglevel trace

然后产生(本文底部有更多日志)

No instrumentation runner found on device 059aaa47 for package com.foobar.mobilern

      at ADB.getInstrumentationRunner (../node_modules/detox/src/devices/drivers/android/exec/ADB.js:250:13)
      at Instrumentation.launch (../node_modules/detox/src/devices/drivers/android/tools/Instrumentation.js:19:24)
      at MonitoredInstrumentation.launch (../node_modules/detox/src/devices/drivers/android/tools/MonitoredInstrumentation.js:18:5)
      at AttachedAndroidDriver._launchInstrumentationProcess (../node_modules/detox/src/devices/drivers/android/AndroidDriver.js:284:5)
      at AttachedAndroidDriver._launchApp (../node_modules/detox/src/devices/drivers/android/AndroidDriver.js:267:7)
      at AttachedAndroidDriver._handleLaunchApp (../node_modules/detox/src/devices/drivers/android/AndroidDriver.js:120:7)
      at AttachedAndroidDriver.launchApp (../node_modules/detox/src/devices/drivers/android/AndroidDriver.js:91:12)
      at Device._doLaunchApp (../node_modules/detox/src/devices/Device.js:85:19)
      at traceCall (../node_modules/detox/src/utils/trace.js:41:20)

如果我从 testBinaryPath 中省略 .detoxrc.json 键,那么我得到 this result

在测试设备上运行 adb -s 059aaa47 shell pm list instrumentation 会产生空响应,因此我倾向于认为某些测试设置没有彻底完成和/或我可能在考虑这个错误

我想我的问题的要点是,是否可以在不使用某种测试工具/二进制文件的情况下测试一个 .apk

Full Log Output

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)