Does running a single test in a Target containing unit tests start by running the actual app?

In V 0.1 of my app, I went with a simple option for a piece of business logic in my app. I then changed something else that caused my simplified business logic to now crash the app at startup. Excellent, a chance to use Test. Driven Design to replace my flawed business logic. So I wrote my first test TDD test, but when I tried to run the test... It doesn't run because running the test target seems to start by actually running my full app (which as I described in chapter 1 is currently crashing)

Have I configured something incorrectly? or is it normal that when I attempt to run a single test, step 1 is running the full app?

(note: it is very easy for me to disable/avoid the business logic causing my crash. This question is more about my lack of understanding of what it means to run a test target.)

thanks in advance for any and all responses.

Mike

Answered by DTS Engineer in 787574022

Xcode’s test targets work in one of two ways:

  • If you set the Test Host build setting, Xcode will start that app and load your test bundle into that.

  • If not, Xcode will start its own test runner executable and use that to load your test bundle.

This build setting has a friendly UI in the General tab of the target editor. Look for the Host Application popup.

Depending on how your code is factored, it might make sense to have two test targets: one with a host application and one without. Then put the tests that need to run in your host application in the first and other tests in the second.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Xcode’s test targets work in one of two ways:

  • If you set the Test Host build setting, Xcode will start that app and load your test bundle into that.

  • If not, Xcode will start its own test runner executable and use that to load your test bundle.

This build setting has a friendly UI in the General tab of the target editor. Look for the Host Application popup.

Depending on how your code is factored, it might make sense to have two test targets: one with a host application and one without. Then put the tests that need to run in your host application in the first and other tests in the second.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Does running a single test in a Target containing unit tests start by running the actual app?
 
 
Q