虽然我在iOS上排毒效果很好,但我的反应原生的android排毒版本在通过排毒cli打开时会启动一个空白屏幕。
在这种状态下,值得一提的是cmd + m
或rr
重新加载。
"react-native": "0.51.0",
...
"detox": "^7.0.0-alpha.0",
...
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "Nexus_5X_API_26"
},
运行时
detox test -c android.emu.debug --loglevel verbose
android apk安装,启动,但卡在空白屏幕。
detox info 15:26:02: server listening on localhost:63324...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"300068b9-c44f-8b8a-81cb-73f8c66b0752","role":"tester"},"messageId":0}
detox verb ws onMessage: {"type":"loginSuccess","params":{"sessionId":"300068b9-c44f-8b8a-81cb-73f8c66b0752","role":"tester"},"messageId":0}
detox verb ws
detox verb 1: /Users/me/Library/Android/sdk/tools/emulator -list-avds --verbose
detox verb 1: stdout: Nexus_5X_API_26
detox verb 1: stdout:
detox verb /Users/me/Library/Android/sdk/tools/emulator -verbose -gpu host -no-audio @Nexus_5X_API_26
detox verb 2: /Users/me/Library/Android/sdk/platform-tools/adb devices
detox verb 2: stdout: List of devices attached
detox verb 2: stdout: emulator-5554 device
detox verb 2: stdout:
detox verb 2: stdout:
detox verb 3: /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell getprop dev.bootcomplete
detox verb 3: stdout: 1
detox verb 3: stdout:
detox verb 4: /Users/me/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell input keyevent 82
detox verb adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:63324 -e detoxSessionId 300068b9-c44f-8b8a-81cb-73f8c66b0752 -e debug false com.mypackage.mobile.test/android.support.test.runner.AndroidJUnitRunner
detox verb Instrumentation spawned, childProcess.pid: 24565
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: numtests=1
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: stream=
detox verb Instrumentation stdout: com.mypackage.mobile.DetoxTest:
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: test=runDetoxTests
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: class=com.mypackage.mobile.DetoxTest
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS: current=1
detox verb Instrumentation stdout:
detox verb Instrumentation stdout: INSTRUMENTATION_STATUS_CODE: 1
detox verb Instrumentation stdout:
2分钟后
detox verb Instrumentation stdout: INSTRUMENTATION_CODE: 0
detox verb Instrumentation stdout:
detox verb instrumentationProcess terminated due to receipt of signal null
1) "before all" hook: _callee
0 passing (2m)
1 failing
1) "before all" hook: _callee:
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
0 passing (2m)
1 failing
1) "before all" hook: _callee:
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
从正在运行react-native log-android
01-17 15:11:01.053 5248 5318 D ReactNative: Initializing React Xplat Bridge.
01-17 15:11:01.055 5248 5318 D ReactNative: Initializing React Xplat Bridge before initializeBridge
01-17 15:11:01.060 5248 5318 D ReactNative: Initializing React Xplat Bridge after initializeBridge
01-17 15:11:01.061 5248 5318 D ReactNative: CatalystInstanceImpl.runJSBundle()
01-17 15:11:01.061 5248 5323 D ReactNative: ReactInstanceManager.setupReactContext()
01-17 15:11:01.061 5248 5323 D ReactNative: CatalystInstanceImpl.initialize()
01-17 15:11:01.065 5248 5323 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
在上述日志之后的某个时间,应用程序会超时,所以我将其删除。当我从模拟器启动相同的应用程序(由detox安装相同的apk)时,它按预期工作!
当apk按预期启动时,来自react-native log-android
的日志具有额外的行
01-17 15:24:10.207 6447 6530 I ReactNativeJS: Running application "MyApp" with appParams: {"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
此时我知道apk很好,所以我尝试了--reuse
标志,但同样的问题。
package com.mypackage.mobile;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import com.wix.detox.Detox;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
@Test
public void runDetoxTests() throws InterruptedException {
Detox.runTests(mActivityRule);
}
}
有没有人知道如何解决它,以便在通过排毒cli运行时,应用程序将按预期启动,而不是我得到的空白屏幕?如果没有,我可以采取一个很好的下一步,从DetoxTest.java隔离启动应用程序的东西?
答案 0 :(得分:0)
如果该应用未启动,则很有可能是Android应用无法正常构建。您可以确保将{android.emu.debug“正确嵌套在package.json
中的detox.configuration下吗
"detox": {
"configurations": {
"android.emu.debug": {
"binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
"build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "Nexus_5X_API_26"
},
}
}
另外,请检查并确保您的android/app/build.gradle
androidTestImplementation(project(path: ":detox"))
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
答案 1 :(得分:0)
我在Android上也遇到了类似的问题。帮助我的部分原因是使用了它:
.collapse{
float:left;
width:100%;
}
我还要在运行测试之前打开模拟器进行测试