Search code examples
iosunit-testingxcodebuildxctest

Xcode 5 xcodebuild unit test seems to return status successful when tests fail


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?


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 :)