OCUnit: How to run tests without running the iPhone simulator?

I follow the iOS Development Guide: Device Testing Applications . However, when I try to build (Command + B) the LogicTests target (step 8 in the “Configuring Logical Testing” section), I get the error message: “The selected destination is not valid for this action”.

Since I added the target application to the LogicTests target dependencies, I can run unit tests using Command + U, but it also launches the iPhone simulator.

To save time and resources, is it possible to run OCUnit tests (both logical and application tests) without running iPhone Simulator?

+4
source share
4 answers

How much time / resources? Instead of focusing on reducing them, I would focus on expanding your tests to go far beyond Apple's original Logic Tests. These recommendations were limited and written before Xcode 4. Now you can write tests without thinking: "Is this a logical test or an application test?" - just check everything.

+1
source

I understand the annoyance of a simulator appearing in unit tests. The best tool I could find was Command + U, and then Command + H when running unit tests. (Control + H hides the simulator after it appears.) Since it appears almost instantly, this can be an effective way to get it out of your range of vision.

+8
source

I managed to run my unit tests, which test my model classes without running the simulator as follows:

  • I did not install any package loader or test host assembly test settings, instead I just added .m files. I was unit testing in Build Phases Compilation Sources.

  • Then I ran unit tests from the command line using:

     xcodebuild -verbose -target TheElementsUnitTests -configuration Debug -sdk iphonesimulator5.0 clean build 

Not quite sure why this didn't start the simulator, but it certainly didn't help!

+4
source

Here is a small AppleScript that I installed to run to display the results in a test configuration:

 #!/usr/bin/osascript activate application "Xcode" 

It returns Xcode immediately after pressing the + U command.

PS I also discovered the error, and Apple marked it as a duplicate. So they know.

+1
source

All Articles