Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

ios - Don't launch simulator when running unittests

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

enter image description here

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...