我正在尝试让ocunit在我的XCode项目中工作。因为我还需要在单元测试中进行调试,所以我使用了一个自动化设置的脚本(见下文)。我只需将其包含在项目的resources下,并将其名称更改为我希望其运行的.ocunit文件。
我得到的问题是它找不到捆绑包文件,因此存在错误。谁能对XCode和objective-c有所了解,看看它,告诉我哪里出了问题。另外,我应该如何生成我需要运行的.ocunit文件。通过为iPhone设置新的单元测试目标并向其添加测试,或者?
希望有人有线索,因为我刚刚开始纽约iPhone开发,需要让它快速启动和运行
Apple脚本
-- The only customized value we need is the name of the test bundle
tell me to activate
tell application "Xcode"
activate
set thisProject to project of active project document
tell thisProject
set testBundleName to name of active target
set unitTestExecutable to make new executable at end of executables
set name of unitTestExecutable to testBundleName
set path of unitTestExecutable to "/Applications/TextEdit.app"
tell unitTestExecutable
-- Add a "-SenTest All" argument
make new launch argument with properties {active:true, name:"-SenTest All"}
-- Add the magic
set injectValue to "$(BUILT_PRODUCTS_DIR)/" & testBundleName & ".octest"
make new environment variable with properties {active:true, name:"XCInjectBundle", value:injectValue}
make new environment variable with properties {active:true, name:"XCInjectBundleInto", value:"/Applications/TextEdit.app/Contents/MacOS/TextEdit"}
make new environment variable with properties {active:true, name:"DYLD_INSERT_LIBRARIES", value:"$(DEVELOPER_LIBRARY_DIR)/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection"}
make new environment variable with properties {active:true, name:"DYLD_FALLBACK_FRAMEWORK_PATH", value:"$(DEVELOPER_LIBRARY_DIR)/Frameworks"}
end tell
end tell
end tell发布于 2010-07-03 22:17:26
看起来该脚本所做的就是编辑xcode以将OCUnits测试注入调试器。实际上并不是用OCUnit构建的。
您确实需要创建一个OCUnit目标,然后创建指向该目标的OCUnit测试用例类。
请查看此处的教程,了解如何在XCode中使用OCUnit。
http://www.mobileorchard.com/ocunit-integrated-unit-testing-in-xcode/
发布于 2011-02-14 15:58:15
在经历了类似的麻烦之后,我总结了我为能够执行单元测试调试而采取的步骤。链接在这里:How to run and debug unit tests for an iphone application
https://stackoverflow.com/questions/3000490
复制相似问题