XCTests在物理设备上失败:“由于超时而取消测试......” [英] XCTests Failing on Physical Device: "Canceling tests due to timeout ..."

查看:113
本文介绍了XCTests在物理设备上失败:“由于超时而取消测试......”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XCTests失败并显示以下消息: ***在等待测试过程中因超时而取消测试... 这刚刚开始出现在最后几天。我正在使用Xcode 7.3.1,在iPhone 6上运行iOS 9.3.2。我的应用主要是在Swift中编写的。

XCTests are failing with the message: *** Canceling tests due to timeout in Waiting for test process to check in... This just started coming up in the last few days. I'm using Xcode 7.3.1, with iOS 9.3.2 running on an iPhone 6. My app is written mostly in Swift.

我看过一些类似的帖子:

I've seen some similar posts:


  1. 无法在iOS设备上运行XCTests

  2. 通过JNLP使用Jenkins时,iOS测试不会在模拟器上运行

  1. Unable to run XCTests on iOS device
  2. iOS tests will not run on simulator when using Jenkins through JNLP

这些其他帖子谈到了代码签名时出现的这个问题。代码签名似乎不是我的问题 - 我查看了KeyChain Access实用程序,但没有看到任何相关的过期证书。此外,到目前为止(非常暂时)修复我的问题是重新启动我的iPhone。 (不幸的是,这个修复程序不会持续很长时间 - 可能是几次XCtests运行并且问题再次出现)。我没有运行Jenkins,只是XCTests。

Those other posts talk about this issue as arising with code signing. Code signing does not seem to be my problem-- I've looked at the KeyChain Access utility and don't see any relevant expired certificates. Also, what so far is (very temporarily) fixing my problem is to restart my iPhone. (Unfortunately, that fix doesn't last long-- maybe a few runs of XCtests and the problem is coming up again). I'm not running Jenkins, just XCTests.

我尝试重新启动Xcode并从DerivedData文件夹中删除所有文件/文件夹,但这些都没有解决问题。

I have tried restarting Xcode and removing all files/folders from the DerivedData folder but neither of these resolves the problem.

只安装Xcode8(第一个beta版)。但除了推出一两次之外,我通常不会使用它。刚出现这个问题后,这个问题似乎很奇怪。

I did just install Xcode8 (first beta release). But aside from having launched it once or twice, I'm not generally using it. It does seem oddly coincidental that this issue is arising after having just installed that.

更新6/25/16

我已经稍微缩小了这个问题。其他几个症状与超时问题同时出现:

I've narrowed this issue down somewhat. Several other symptoms appear at the same time as the timeout issue:


  1. 控制台直接从打印语句停止。

  2. 计时器失败 - 这实际上是问题的根源。我的测试涉及首先等待一些服务器交互,这发生了。但等待使用的NSTimer从不执行其回调。

  3. 断点停止工作。

  1. Console logging directly from print statements in the XCTest files stops.
  2. Timer's fail-- this is actually the root of the problem. My tests involve first waiting for some server interaction, which occurs. But the wait uses an NSTimer which never executes its callback.
  3. Breakpoints stop working.

值得注意的是,我正在运行这些XCTest的手动。也就是说,我分别运行每个测试,因此每个测试都涉及构建。

It seems worthwhile to note that I'm running these XCTest's manually. That is, I am running each test separately, so each test involves a build.

此外,到目前为止,我测试了以下内容:

Also, so far I have tested the following:


  1. 重启Xcode(没有帮助)

  2. 重启Mac OS X(没有帮助)

  3. 删除派生数据内容(没有帮助)

  4. 重新启动iPhone--有帮助,但只能再次运行几个Xcode测试。

  5. 尝试在iPhone上使用wifi与热点运行(无需更改)

  6. TODO:使用模拟器运行

  7. 这可能是电缆还是USB端口问题?更换连接设备的电缆无济于事。

  8. 删除应用并重新安装/重建无济于事。

  9. 尝试使用不同的硬件( iPad Air运行iOS 9.3.2)。同样的问题。

  1. Restarting Xcode (doesn't help)
  2. Restarting Mac OS X (doesn't help)
  3. Removing Derived Data contents (doesn't help)
  4. Restarting iPhone-- helps, but only again allows a few Xcode tests to run.
  5. Tried running with wifi versus hotspot on iPhone (no change to issue)
  6. TODO: Running with simulator
  7. Could this be a cable or USB port issue? Changing the cable connecting the device doesn't help.
  8. Deleting the app and reinstalling/rebuilding doesn't help.
  9. Tried on different hardware (iPad Air running iOS 9.3.2). Same issues.

我的配置是:iOS 9.3.2,Xcode 7.3.1,Mac OS X 10.11.5(15F34)。

My configuration is: iOS 9.3.2, Xcode 7.3.1, Mac OS X 10.11.5 (15F34).

推荐答案

问题在于(或者更确切地说:xcodebuild中的严重错误)连接到XCTest服务器的超时开始此时你发出命令xcodebuild。超时为120秒,因此如果您的编译+模拟器启动时间超过2分钟,xcodebuild将给出由于超时而取消测试错误。

The problem lies in the fact (or rather: serious bug in xcodebuild) that the timeout for connecting to the XCTest server starts at the moment you issue the command xcodebuild. The timeout is 120 seconds, so if your compilation + startup of the simulator takes longer than 2 minutes xcodebuild will give this "Canceling tests due to timeout" error.

解决方案是将构建分解为两个命令。一个用于构建,一个用于运行测试:

The solution is to break up the build into two commands. One for building and one for running the tests:

> xcodebuild clean build build-for-testing <other options>
> xcodebuild test-without-building <other options>

这将解决超时问题,因为test-without-building操作不必编译首先。

This will solve the timeout issue, because the test-without-building action doesn't have to compile first.

这篇关于XCTests在物理设备上失败:“由于超时而取消测试......”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆