React Native 应用程序在运行 Detox e2e 测试套件之前重新启动。最初,它显示应用程序的第一个屏幕并重新启动应用程序测试套件。
这种行为的问题在于,当我尝试在 com.bitbar.com 设备农场服务门户上运行测试套件时,测试用例成功运行,而它必须失败并将日志写入文件。
我在本地对其进行了测试,如果我们不尝试将记录记录到日志文件中,那么它会成功运行应用程序,但是如果我们尝试将记录记录到日志文件中,那么测试用例首先会停止(不必要的)屏幕启动,使测试用例通过。如何停止排毒测试用例的这种行为。
测试用例:
describe('Example', () => {
it('Login Screen, Logging into the app', async () => {
await device.reloadReactNative();
await element(by.id(TestIDs.LoginScreen.usernameInput)).typeText('+1234567890');
await element(by.id(TestIDs.LoginScreen.passwordInput)).typeText('0123');
await Expect(element(by.id('not found'))).toBeVisible();
await Expect(element(by.id(TestIDs.LoginScreen.submitButton))).toBeVisible();
// await element(by.id(TestIDs.LoginScreen.submitButton)).tap();
})
命令运行测试而不将日志保存到
detox test --configuration android.emu.debug -l verbose
命令运行测试并将日志保存到
"detox test --configuration android.emu.debug -l verbose > detox.log 2>&1 "
日志
`
send: {"type":"isReady","params":{},"messageId":-1000}
INSTRUMENTATION_STATUS: class=com.mobile.repletehealth.DetoxTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
com.mobile.repletehealth.DetoxTest:
INSTRUMENTATION_STATUS: test=runDetoxTests
INSTRUMENTATION_STATUS_CODE: 1
nstrumentation stdout:
onMessage: {"messageId":-1000,"type":"ready","params":{}}
rbx
send: {"type":"reactNativeReload","params":{},"messageId":-1000}
onMessage: {"messageId":-1000,"type":"ready","params":{}}
rbx
send: {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["usernameInput"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.action.ViewActions"},"method":"typeText","args":["+1234567890"]}}]},"messageId":1}
onMessage: {"messageId":1,"type":"invokeResult","params":{"result":"(null)"}}
rbx
send: {"type":"invoke","params":{"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["passwordInput"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"android.support.test.espresso.action.ViewActions"},"method":"typeText","args":["0123"]}}]},"messageId":2}
onMessage: {"messageId":2,"type":"invokeResult","params":{"result":"(null)"}}
rbx
send: {"type":"cleanup","params":{"stopRunner":true},"messageId":3}
onMessage: {"messageId":3,"type":"cleanupDone","params":{}}`