Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITest的简单XTest总是失败?_Ios_Objective C_Xcode_Xctest_Xcode Ui Testing - Fatal编程技术网

Ios UITest的简单XTest总是失败?

Ios UITest的简单XTest总是失败?,ios,objective-c,xcode,xctest,xcode-ui-testing,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 Failur

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

我向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'
现在我添加一个断点,如下所示:


现在测试成功了!任何人都可以解释原因吗?

当iOS模拟器已经启动时,我发现了这个错误(这不一定意味着你可以在OS X dock中看到它)。您可以使用
simctl
命令检查各种模拟器的状态

然后,确保所有列为“启动”的设备都已关闭:

xcrun simctl shutdown <device-udid-here>
xcrun simctl关机

然后,再次尝试运行UI测试。

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

我很久以前也遇到过类似的问题。我注意到此崩溃可能与应用程序启动处理有关。苹果似乎已经为测试实例设置了一个超时,如果该实例在超时之前没有收到应用程序的响应,该实例将被终止,应用程序将在
[app launch]崩溃位置。@Bluewings我是否能够更改此超时时间,并且我的应用程序只有一个视图!!!抱歉,我们无法更改暂停时间。@Bluewings您当时是如何解决此问题的?我不确定这是您遇到的确切问题。但当我在OSX服务器上测试相同的代码时,它得到了修复,虽然很奇怪,但现在运行良好
xcrun simctl shutdown <device-udid-here>