我是否可以在XCTest中调用API调用setUP()或tearDown()以在测试之间重置应用程序?我查看了XCUIApplication的点语法,我看到的只是.launch()
或者有没有办法在Swift中调用shell脚本?然后我可以调用xcrun中间的测试方法来重置模拟器.
正如标题所示,我确实使用 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)
模拟器:
感谢协助
其他尽职调查: