Xcode 4.5命令行单元测试 [英] Xcode 4.5 command line unit testing

查看:116
本文介绍了Xcode 4.5命令行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过命令行运行我的单元测试时更新到Xcode 4.5后出现问题。
以下是我尝试运行测试时看到的输出

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.

我正在使用以下命令来运行测试
xcodebuild -workspace MyApp.xcworkspace -scheme MyAppTests -sdk iphonesimulator -configuration Debug clean build TEST_AFTER_BUILD = YES

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?

推荐答案

我想我也应该分享我为解决这个问题所做的工作。我按照 https://stackoverflow.com/a/10823483/666943 中列出的解决方案,但将ruby脚本转换为shell 。最后我基本上通过自制软件安装 ios-sim 并替换中的运行脚本使用以下内容构建我的测试目标的阶段

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

现在开始测试我传入参数 RUN_UNIT_TEST_WITH_IOS_SIM = YES 例如

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

这篇关于Xcode 4.5命令行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆