我在Xcode7.3 / iOS9.3上的UI测试中看到了大约1/10次
Test Case '-[WhatevUITests.RegistrationUITests testVerifyUnsupportedPhoneNumberAlert]' started.
t = 0.00s Start Test
t = 0.00s Set Up
t = 0.01s Launch me.jackpine.whatev-dev
t = 0.11s Terminate <XCUIApplicationProcess: 0x7ff91a712550 me.jackpine.whatev-dev (94280)>
t = 1.14s Assertion Failure: UI Testing Failure - Failure attempting to launch <XCUIApplicationImpl: 0x7ff91a49fae0 me.jackpine.whatev-dev at /Users/mkirk/src/jackpine/Whatev-iOS/build/Whatev/Build/Products/Debug-iphonesimulator/Whatev Dev.app>, nil token for current process reference <XCUIApplicationProcess: 0x7ff91a624440 me.jackpine.whatev-dev (94333)>
/Users/mkirk/src/jackpine/Whatev-iOS/WhatevUITests/RegistrationUITests.swift:16: error: -[WhatevUITests.RegistrationUITests testVerifyUnsupportedPhoneNumberAlert] : UI Testing Failure - Failure attempting to launch <XCUIApplicationImpl: 0x7ff91a49fae0 me.jackpine.whatev-dev at /Users/mkirk/src/jackpine/Whatev-iOS/build/Whatev/Build/Products/Debug-iphonesimulator/Whatev Dev.app>, nil token for current process reference <XCUIApplicationProcess: 0x7ff91a624440 me.jackpine.whatev-dev (94333)>
t = 1.15s Tear Down
我不确定这意味着什么。通常我可以重新运行测试,它会毫无问题地完成。
答案 0 :(得分:0)
我在Xcode 8.3.2和iOS 10.3 Simulator中遇到过这个问题。将Mac OS更新到Sierra后,所有测试都开始失败。
我们会在以下位置看到上述异常:
XCUIApplication().launch()
并且第一次测试尝试访问XCUIApplication()时崩溃。
修复是将XCUIApplication()。launch()调用移动到setUp()函数。
<强>背景强>
在我们的例子中,问题是多线程。我们想确保在应用程序启动之前执行了其他一些代码。该代码运行异步并在返回后启动应用程序。该修复程序确保首先在主线程上启动应用程序。现在一切正常。