Question

Hi I'm following examples from Test Driven iOS development and I've written a few unit tests with the new Xcode 5 and XCTest. My tests fail with the Xcode GUI client, but when I use xcodebuild the status code is 0.

xcodebuild -target TemperatureConverterTests build

and

echo $?

returns 0.

The tests are suppose to fail. Is the command to run the test cases correct?

Was it helpful?

Solution

xcodebuild command has changed with xcode 5. Here is a script to run Unit tests :

Don't forget that schemes must be shared, you've got to create your Tests Scheme, Xcode 5 didn't create it for you

xcodebuild -workspace MyApp.xcworkspace -scheme myApp-Tests -destination=build -configuration Debug -sdk iphonesimulator7.0 ONLY_ACTIVE_ARCH=YES clean build test

Hope this helps :)

OTHER TIPS

If you don't want (as you rarely need) a separate (and annoying) "scheme" for your testing "target"... Use a variation on @Rémy Virin's answer...

xcodebuild -scheme YourAppOrLib -target YourAppOrLibTests

As pictured below.. this allows you to run the Unit tests for the target.... without cluttering the project with non-production schemes... In this case IndexedKeyMap is my YourAppOrLib.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top