4

我正试图让 ocunit 从 XCode 在我的项目中工作。因为我还需要在单元测试中进行调试,所以我使用了一个自动化设置的脚本(见下文)。我只是将它包含在资源下的项目中,并将名称更改为我希望它运行的 .ocunit 文件。

我得到的问题是它找不到捆绑文件,因此存在错误。任何对 XCode 和 Objective-c 有所了解的人都可以看看它并告诉我出了什么问题。另外我应该如何生成我需要运行的 .ocunit 文件。通过为 iPhone 设置新的单元测试目标并向其添加测试?

希望有人知道,因为我刚刚开始进行 iPhone 开发,需要快速启动并运行

苹果脚本

-- 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
4

2 回答 2

2

在经历了类似的麻烦之后,我总结了我为能够执行单元测试调试而采取的步骤。链接在这里: 如何运行和调试 iphone 应用程序的单元测试

于 2011-02-14T07:58:15.453 回答
2

看起来该脚本所做的是编辑 xcode 以将 OCUnits 测试注入调试器。实际上不是用 OCUnit 构建的。

您确实需要创建一个 OCUnit 目标,然后创建指向该目标的 OCUnit 测试用例类。

在此处查看教程以了解如何将 OCUnit 与 XCode 一起使用。

http://www.mobileorchard.com/ocunit-integrated-unit-testing-in-xcode/

于 2010-07-03T14:17:26.253 回答