iPhone 上的 ocunit 测试
我正在尝试让 ocunit 从 XCode 在我的项目中工作。由于我还需要在单元测试中进行调试,因此我使用了一个自动执行设置的脚本(见下文)。我只是将其包含在资源下的项目中,并将名称更改为我希望它运行的 .ocunit 文件。
我遇到的问题是它找不到捆绑文件,因此存在错误。 任何对 XCode 和 Objective-C 有了解的人都可以看一下并告诉我出了什么问题吗?另外我应该如何生成我需要运行的 .ocunit 文件。通过为 iPhone 设置新的单元测试目标并向其添加测试还是?
希望有人能提供线索,因为我刚刚开始 iPhone 开发,需要快速启动并运行
Apple Script
-- 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
I am trying to get ocunit working in my project from XCode. Since I also need to debug in the unit tests I am using a script that automates the setup (see below). I just include it in the project under resources and change the name to the .ocunit file I want it to run.
The problem I get is that it cant find the bundle file and therefore exists with an error.
Can anyone who has a clue about XCode and objective-c take a look at it and tell me what is wrong. Also how am I supposed to produce the .ocunit file that I need to run. By setting up a new unit test target for the iPhone and add tests to it or?
Hope someone has a clue since I just started ny iPhone development and need to get it up and running quickly
Apple Script
-- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来该脚本的作用是编辑 xcode 以将 OCUnits 测试注入调试器。实际上并不是用 OCUnit 构建的。
您需要创建一个 OCUnit 目标,然后创建指向该目标的 OCUnit 测试用例类。
查看此处的教程,了解如何将 OCUnit 与 XCode 结合使用。
http://www.mobileorchard.com/ocunit-integrated-unit -测试-in-xcode/
Looks like what that script does is edit xcode to inject OCUnits tests into the debugger. Not actually build with OCUnit.
You DO need to create an OCUnit target, and then create OCUnit test case classes that point to that target.
Check the tutorial here for how to use OCUnit with XCode.
http://www.mobileorchard.com/ocunit-integrated-unit-testing-in-xcode/
我自己也经历过类似的麻烦,我总结了我为能够执行单元测试调试而采取的步骤。链接在这里:
如何运行和调试 iPhone 的单元测试应用程序
Having gone through similar hassle myself I've put together a summary of the steps I took to be able to perform debugging of my unit tests. The link is here:
How to run and debug unit tests for an iphone application