Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
407 views
in Technique[技术] by (71.8m points)

ios6 - Xcode 4.5 command line unit testing

Having an issue since updating to Xcode 4.5 when running my unit tests via command line. The following is the output i'm seeing when i try to run my tests

Unknown Device Type. Using UIUserInterfaceIdiomPad based on screen size
Terminating since there is no workspace.
/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:334: note: Passed tests for architecture 'i386' (GC OFF)

/Applications/Xcode.app/Contents/Developer/Tools/RunPlatformUnitTests.include:345: note: Completed tests for architectures 'i386'

Even though it does say the tests have passed and completed, I don't think they have actually have been run.

I'm using the following command to run the tests:

xcodebuild -workspace MyApp.xcworkspace -scheme MyAppTests -sdk iphonesimulator -configuration Debug clean build TEST_AFTER_BUILD=YES

Has anyone run into the same problem and can offer a solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just thought I should also share what I did for a solution to this issue. I followed the solution outlined in https://stackoverflow.com/a/10823483/666943 but converted the ruby script to shell. At the end I basically installed ios-sim via homebrew and replace the Run Script in the Build Phases of my Test target with the following:

if [ "$RUN_UNIT_TEST_WITH_IOS_SIM" = "YES" ]; then
    test_bundle_path="$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.$WRAPPER_EXTENSION"
    ios-sim launch "$(dirname "$TEST_HOST")" --setenv DYLD_INSERT_LIBRARIES=/../../Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection --setenv XCInjectBundle="$test_bundle_path" --setenv XCInjectBundleInto="$TEST_HOST" --args -SenTest All "$test_bundle_path"
    echo "Finished running tests with ios-sim"
else
    "${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"
fi

To start the test now I pass in the argument RUN_UNIT_TEST_WITH_IOS_SIM=YES e.g.

xcodebuild -workspace MyApp.xcworkspace -scheme MyAppTests -sdk iphonesimulator -configuration Debug clean build RUN_UNIT_TEST_WITH_IOS_SIM=YES

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...