views:

183

answers:

1

Hi

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

Cheers

Magnus

A: 

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/

Chad