简体   繁体   English

在运行Mountain Lion(OS X 10.8.5)的Mac上进行iOS单元测试

[英]iOS unit testing on a Mac running Mountain Lion (OS X 10.8.5)

I have an iOS project that comes from an older Xcode (4.6.3) and that did not include a test target by default, as projects in latest Xcode versions seem to include. 我有一个来自较旧的Xcode(4.6.3)的iOS项目,默认情况下不包含测试目标,因为最新的Xcode版本中的项目似乎包括在内。 I now have Xcode 5.1.1. 我现在有Xcode 5.1.1。 on a Mac that is running OS X 10.8.5. 在运行OS X 10.8.5的Mac上。 I've reading this Apple's document regarding unit testing in Xcode, but it looks like you need OS X Mavericks, at least for installing and configuring OS X Server, don't you? 我已经阅读了这份有关Xcode中的单元测试的Apple文档 ,但是看来您需要OS X Mavericks,至少是用于安装和配置OS X Server,不是吗?

I'd appreciate some guidelines to follow to add a test target to my project and how could I integrate a testing process in my workflow if I do not have OS X Maveriks. 我希望能遵循一些指导方针,以将测试目标添加到我的项目中,如果没有OS X Maverik,如何将测试过程集成到我的工作流程中。

Thanks in advance 提前致谢

EDIT: Is there anyway of run tests in normal running of the app? 编辑:在应用程序的正常运行中总有运行测试吗? I mean, I need to test some cases that involve the update of data at certain hours, and the update of some parameters and the GUI after that data update... how could I do this? 我的意思是,我需要测试某些情况,这些情况涉及某些小时的数据更新,以及在数据更新后某些参数和GUI的更新...我该怎么做? Thanks 谢谢

You need Mavricks if you wish to use the Xcode service, which is Apple's continuous integration server. 如果您想使用Xcode服务(Apple的持续集成服务器),则需要Mavricks。 You do not need Mavricks to run unit tests, however you will miss out on the pretty in-xcode reports. 您不需要Mavricks来运行单元测试,但是您会错过漂亮的xcode报告。

Without Mavericks, you can run unit tests manually by pressing CMD+U or going to Product->Test . 如果没有Mavericks,则可以通过按CMD+U或转到Product->Test来手动运行单元Product->Test

You can also setup your own continuous integration service and run the unit tests with a command line script. 您还可以设置自己的持续集成服务,并使用命令行脚本运行单元测试 You'll have to pick a CI server, something like Jenkins or many alternatives, and look up a how-to for that system. 您将不得不选择CI服务器(例如Jenkins或其他替代产品),并查找该系统的使用方法。

Do you redirect NSLog/stderr anywhere? 您是否将NSLog / stderr重定向到任何地方?

I encountered this problem too with no red marks and failing test of '1 == 1'. 我也遇到了这个问题,没有红色标记,并且测试'1 == 1'失败。

My app was catching NSLog calls to a file and not letting the system get them. 我的应用程序正在捕获对文件的NSLog调用,而不是让系统获取它们。 Once I disabled the redirecting of logs freopen(filepath, "a", stderr) test started passing and green checks and red crosses appeared. 一旦禁用日志的重定向, freopen(filepath, "a", stderr)测试便开始通过,并出现绿色检查和红叉。

I did this for an external accessory device that hooked up through the lightning port and couldn't send the logs to the mac. 我这样做是为了通过闪电端口挂接的外部附件设备,无法将日志发送到mac。 You mentioned how you want to run the test during the normal running of you app, so I figured you may have saved the logs so you could read them away from you mac. 您提到了如何在应用正常运行期间运行测试,所以我认为您可能已经保存了日志,因此可以从Mac上读取它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM