XCUITest 在 TearDown 期间随机失败 - “无法终止 com.bundle.id”

Dar*_*Teo 5 xcode swift xcuitest

正如标题所示,我确实使用 UI 测试创建了一个新项目,但它失败了。

/.../Test2/Test2UITests/Test2UITests.swift:37: error: -[Test2UITests.Test2UITests testLaunchPerformance] : Failed to terminate com.darylteo.Test2.Test2:27031: Failed to terminate com.darylteo.Test2.Test2:0
    t =    60.29s Tear Down
Test Case '-[Test2UITests.Test2UITests testLaunchPerformance]' failed (60.288 seconds).
Test Suite 'Test2UITests' failed at 2022-09-18 13:34:26.714.
     Executed 2 tests, with 1 failure (0 unexpected) in 65.396 (65.400) seconds

Run Code Online (Sandbox Code Playgroud)

该应用程序在模拟器中只是变黑,但模拟器仍然是交互式的,并且该应用程序可以硬停止。我无法运行单个测试套件而不以这种方式失败,并且反复运行单个测试会遇到相同的问题(一次有效,下一次失败)

我猜测这可能是与模拟器的调试连接有关的某种问题,但这种不稳定完全使 XCUITest 毫无用处。

  • M1 MacBook Pro 16 英寸(带 Pro Max)

  • 蒙特利 12.5.1 (21GB3)

  • XCode 版本 14.0 (14A309)

  • 模拟器:

    • 版本 14.0 (986.3)
    • 模拟器套件 624
    • 核心模拟器 857.7

感谢协助

测试失败 错误

其他尽职调查:

Dar*_*Teo 0

发现问题了。我在 Rosetta 模式下运行 XCode,因为另一个项目具有尚未为 m1 编译的依赖项。

禁用 Rosetta,问题不再存在。

希望这可以帮助 :)