运行单元测试时不要启动模拟器 [英] Don't launch simulator when running unittests

查看:181
本文介绍了运行单元测试时不要启动模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些背景信息:



我有iOS应用程序,其目标配置为运行unitTests。我在我的MacBook上运行构建自动化工具jenkins,它自动构建这个应用程序并运行所有测试(使用命令行xcodebuild工具)。



Xcode 4一切正常。这个构建自动化工具在不同的用户下运行,并且正在运行所有这些测试。



我最近切换到Xcode 5并且它开始失败,因为它无法启动模拟器。



问题



我有一个方案UnitTests配置为运行测试(逻辑测试)。 AI使用以下两种方法之一运行这些测试:




  • Xcode中的命令U


  • 或命令行/ usr / bin / xcodebuild -scheme UnitTests -sdk iphonesimulator -configuration Release clean build TEST_AFTER_BUILD = YES




在这两种情况下,它都会尝试启动模拟器。但是,根据我的理解,它并不需要它。无论如何它运行在顶级x86上,它看起来不像在Simulator上安装任何应用程序。



有没有办法摆脱这个讨厌的模拟器启动(因为它打破我的构建自动化)?



更新1



似乎找到非常相似的问题,但不能让它工作:



2。如果你没有xctool,请安装xctool。

  brew install xctool 

3。使用带xctool的终端运行测试。

  xctool -workspace yourWorkspace.xcworkspace -scheme yourScheme run-tests -sdk iphonesimulator 


Some background:

I have iOS application with a target configured to run unitTests. And I am running build automation tool jenkins on my MacBook which automatically builds this application and run all tests (using command line xcodebuild tool).

Everything worked fine with Xcode 4. This build automation tool was running under different user and was running all these tests.

I switched to Xcode 5 recently and it started to fail, because it can't launch Simulator.

The problem

I have a scheme UnitTests which is configured to run tests (logic tests). A I run these test using one of two methods:

  • Command U in Xcode

  • Or command line "/usr/bin/xcodebuild -scheme UnitTests -sdk iphonesimulator -configuration Release clean build TEST_AFTER_BUILD=YES "

In both cases, it tries to start simulator. However, per my understand it doesn't need it. Anyway it runs on top x86 and it doesn't look like any apps are installed on Simulator.

Is there a way to get rid of this pesky simulator start (because it breaks my build automation)?

Update 1

Seems to find very similar question, but can't get it working: Run logic tests in Xcode 4 without launching the simulator

Update 2

I found VERY relevant and interesting question/answer: Apple CI / Xcode Service and Jenkins

解决方案

Using xCode 7 and xCtool.

xctool is capable of executing unit tests without the simulator.

To get this working,

1 . Update target settings to run without a host app.

Select your project --> then test target --> Set the host application to none.

2. Install xctool , if you don't have it.

brew install xctool

3. Run the tests using terminal with xctool.

xctool -workspace yourWorkspace.xcworkspace -scheme yourScheme run-tests -sdk iphonesimulator

这篇关于运行单元测试时不要启动模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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