Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically change target for unit tests in Xcode 7?

I have a project that has multiple different targets/schemes (~38 of them as of writing this question) and I am trying to get unit testing working properly across all of the different targets. I got things working with one target, and tried adding my testing target to all of the different schemes, but it looks like when tests run for each scheme they actually run on the same, original target.

Looking in the project file I see that there's a specific Host Application associated with my testing target, and in the build settings the Bundle Loader and Test Host point to that same Host Application.

Is there any way to override those values for each scheme to run the tests against the current scheme's build target? Or some other way to set up a single test target to run across multiple build targets?

like image 531
sfeuerstein Avatar asked Dec 30 '15 22:12

sfeuerstein


2 Answers

If you run the tests from the command line, or from an CI tool, like Jenkins, you can instruct xcodebuild to use the build settings that you provide. A simple usage example would be:

xcodebuild -scheme SomeScheme test TEST_HOST=target

You can control almost (if not any) build setting from Xcode, like code coverage generation, build directory, derived data directory, code sign identity, etc.

like image 79
Cristik Avatar answered Nov 17 '22 05:11

Cristik


You can select the scheme when you run tests with Xcode server.

Look at WWDC 2014 continues integration talk for a walk through on how to set it up

https://developer.apple.com/videos/play/wwdc2014-415/

It's using Xcode 6 but it's very similar process to Xcode 7

Also check this CI(continues integration) guideline from apple https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/adopt_continuous_integration.html

like image 34
Tomer Even Avatar answered Nov 17 '22 06:11

Tomer Even