Enable ‘Run’ in the ‘Build’ section of your test bundle’s scheme. (See http://www.raingrove.com/2012/03/28/running-ocunit-and-specta-tests-from-command-line.html)
Install the Kicker tool and the dependencies
$ gem install kicker open4 colored xcodebuild-rb
$ curl https://raw.github.com/gist/3011214/8f660de3ef091770290660680e7c195052b3b0e0/kick.rb > .kick
$ curl https://raw.github.com/gist/3011214/b1dd39b5509a87e16c691177926eced004fa2d14/run-tests.rb > run-tests
$ chmod +x run-tests
$ edit .kick
$ edit run-tests
$ kicker -c
And an example of the output:
21:04:55.90 | Executing: xcodebuild -sdk iphonesimulator -workspace AppName.xcworkspace -scheme AppUnitTests build
Building target: AppUnitTests (in AppName.xcproject)
====================================================
Configuration: Debug
................................
Finished in 2.041412 seconds.
Build succeeded.
21:04:59.47 | Success
21:04:59.47 | Executing: ./run-tests AppPostsSyncSpec
2012-07-05 21:05:02.204 otest[8715:7803] + 'AppPostsSyncSpec synchronizes remote Posts with the local DB' [PASSED]
Executed 1 test, with 0 failures (0 unexpected) in 2.188 (2.213) seconds
21:05:02.21 | Success
This looks more promising than my approach. Does it run UI-dependent unit tests from the command line? (ie. something that creates a UIFont or something)
Last time I looked, I thought otest only ran 'logic' unit tests and you needed to actually boot the app in the simulator with the right dynamic load paths set for it to run the tests, but maybe I was misinformed? (my approach was to try and reproduce this functionality, by writing code that would automatically load tests with dlopen and run the tests when the host app was run using waxsim or ios-sim).
My attempts to reproduce the functionality of Apple's RunPlatformUnitTests shell script haven't worked with the recent Xcode 4.5 developer previews. They do work under 4.4 though, as long as you do the standard hack of editing a copy of the shell script.
I'd love to see this kind of functionality built into the xcodebuild-rb or xcoder gems. xcoder has a nice output formatter for Kiwi/OCUnit tests that might be useful too.