ios - 用于 UITest 的简单 XCTest 总是失败?

标签 ios objective-c xcode xctest xcode-ui-testing

我从文件 -> 新建 -> 项目开始一个新项目

我向 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'

现在我添加一个断点如下:

enter image description here

测试成功!谁能解释一下原因?

最佳答案

我也遇到了同样的问题,但没有一个可用的解决方案适合我。问题是不允许应用程序附加到模拟器本身。 我检查了日志,发现我在定位元素时在代码中犯了一个错误。对于 Predicate 而不是 BEGINSWITH,我写了 STARTSWITH 并且这停止了应用程序的附加。 因此,请检查测试报告中的日志以了解问题。

关于ios - 用于 UITest 的简单 XCTest 总是失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36025580/

相关文章:

iphone - 如何检查音乐在AudioQueue中是播放还是暂停

ios - 如何增加 Xcode 自动完成建议窗口的宽度

objective-c - NSString 和崩溃

ios - 快速解析嵌套的 JSON 属性

iOS:检测touchEnded是否来自滑动屏幕或抬起手指?

objective-c - 继续检查直到 True

ios - iOS Facebook SDK V 3.0 上的重复符号 SBJSON

ios - 查看 NSDictionary 键是否在另一个 NSArray 中

iphone - 使用XCode进行调试时,应用可以正常运行,在设备或模拟器上运行时,应用会崩溃

objective-c - "Clean and Build"到底是做什么的?