【问题标题】:Intermittent "Failure attempting to launch" in ios UITestios UITest中的间歇性“尝试启动失败”
【发布时间】:2016-04-04 21:18:53
【问题描述】:

我在 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

我不确定这意味着什么。通常我可以重新运行测试,它会毫无问题地完成。

【问题讨论】:

  • 另外值得注意的是:我没有在 Xcode 7.2 / iOS 9.2 上看到相同的 UI 测试
  • 你能发布一个重现失败的代码的小样本吗?我可能有一个解决方法,但如果没有看到你的代码就不能肯定地说。
  • 关于这个问题的任何更新?我也面临类似的问题 Xcode 7.3.1
  • 在 Xcode 8.2.1 中也看到了这个

标签: ios xcode-ui-testing


【解决方案1】:

我在使用 Xcode 8.3.2 和 iOS 10.3 模拟器时遇到了这个问题。将 Mac OS 更新到 Sierra 后,所有测试都开始失败。

我们会在以下位置看到上述异常:

XCUIApplication().launch()

当测试第一次尝试访问 XCUIApplication() 时,它会崩溃。

修复方法是将 XCUIApplication().launch() 调用移至 setUp() 函数。

背景

在我们的例子中,问题是多线程。我们想确保在应用程序启动之前执行了一些其他代码。该代码异步运行并在返回后启动应用程序。该修复确保应用程序首先在主线程上启动。现在一切都恢复正常了。

【讨论】:

    猜你喜欢
    • 2019-04-18
    • 2011-10-21
    • 1970-01-01
    • 1970-01-01
    • 2019-05-17
    • 2016-04-11
    • 2017-04-19
    • 1970-01-01
    • 2023-04-02
    相关资源
    最近更新 更多