我从文件 -> 新建 -> 项目开始一个新项目
我向 ViewController 添加了一个按钮。
我默认打开xcode创建的UITest文件夹。运行测试代码。
失败了:
2016-03-16 12:57:09.191 XCTRunner[3511:150419] Continuing to run tests in the background with task ID 1
t = 10.18s Assertion Failure: UI Testing Failure - Failed to background test runner.
/Users/Bernard/Desktop/ExampleTestApplication/ExampleTestApplicationUITests/test2.m:27: error: -[test2 testExample] : UI Testing Failure - Failed to background test runner.
2016-03-16 12:57:12.789 XCTRunner[3511:150419] *** Terminating app due to uncaught exception '_XCTestCaseInterruptionException', reason: 'Interrupting test'
现在我添加一个断点如下:
测试成功!谁能解释一下原因?
最佳答案
我也遇到了同样的问题,但没有一个可用的解决方案适合我。问题是不允许应用程序附加到模拟器本身。 我检查了日志,发现我在定位元素时在代码中犯了一个错误。对于 Predicate 而不是 BEGINSWITH,我写了 STARTSWITH 并且这停止了应用程序的附加。 因此,请检查测试报告中的日志以了解问题。
关于ios - 用于 UITest 的简单 XCTest 总是失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36025580/