排毒测试:未找到 React 本机 android 应用程序二进制文件

Posted

技术标签:

【中文标题】排毒测试:未找到 React 本机 android 应用程序二进制文件【英文标题】:Detox test: React native android app binary not found 【发布时间】:2021-06-07 09:20:06 【问题描述】:

我正在尝试使用 detox 来测试我的 react 本机应用程序。我成功运行 detox build --configuration android.emu.debug,但是当我运行 detox test --configuration android.emu.debug 时,出现错误:

错误:在“xxx/xxx/android/app/build/outputs/apk/androidTest/debug/app-debug.apk”中找不到应用程序二进制文件,您是否构建了它?

我更改了路径,但它不起作用。我该如何解决这个问题?

  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "configurations": 
    "ios": 
      "type": "ios.simulator",
      "binaryPath": "./ios/build/Build/Products/Debug-iphonesimulator/xxx.app",
      "build": "xcodebuild -workspace iOS/xxx.xcworkspace -scheme xxx -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
      "device": 
        "type": "iPhone 11"
      
    ,
    "android.emu.debug": 
      "device": 
        "avdName": "Pixel_API_28_AOSP"
      ,
      "type": "android.emulator",
      "binaryPath": "android/app/build/outputs/apk/androidTest/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd .."
    ,
    "android.emu.release": 
      "device": "emulator",
      "type": "android.emulator",
      "app": "android.release"
    
  

它适用于 iOS

【问题讨论】:

你的 android binaryPath 是错误的。它应该是这样的 android 调试和发布。 "binaryPath": "android/app/build/outputs/apk/release/app-release.apk" 【参考方案1】:

在 android.emu.debug 的 binaryPath 下添加这个来覆盖当前正在查看的测试 apk detox:

"testBinaryPath":"android/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk"

或者如果您的 app-debug-androidTest.apk 位于其他位置,请确保将其路径添加为 testBinaryPath 的值。

快乐编码^^。

【讨论】:

以上是关于排毒测试:未找到 React 本机 android 应用程序二进制文件的主要内容,如果未能解决你的问题,请参考以下文章

“资源 android:attr/fontVariationSettings 未找到。”在本机反应

排毒测试分配给未定义,所有e2e都被跳过

排毒(Android):device.reloadReactNative 失败

排毒没有传入环境变量

没有模拟器的 iPad 上的排毒测试

使用 React Native 进行排毒 UI 测试非常慢