On Jun 10, 2005, at 6:42 AM, Jesse Grosjean wrote: But sometimes (when the tests don't run) I would like to set breakpoints in my test cases and break into XCode's debugger. Is that possible? How do I turn debugging on for the new built in unit testing?
It is possible, you'll need to set up your application executable in Xcode to support this. You'll need to specify an argument and two environment variables. You can do this by highlighting your application in the Executables group of your Xcode project and getting info on it.
The argument you'll need to specify is "-SenTest All" - this indicates to the testing framework that it should run all tests.
The environment variables you'll need to specify are DYLD_INSERT_LIBRARIES and XCInjectBundle. You use DYLD_INSERT_LIBRARIES to force a helper library we've supplied to load into your application when it's launched. XCInjectBundle gives that library the path to a bundle of unit tests to load. Here's how you should set them:
DYLD_INSERT_LIBRARIES=/System/Library/PrivateFrameworks/DevToolsBundleInjection.framework/DevToolsBundleInjection
XCInjectBundle=$(BUILT_PRODUCTS_DIR)/YourTestBundleName.octest
Once you do this, you should be able to set breakpoints in your unit tests and then launch your application under the debugger. (Be sure, of course, to use "Debug" rather than "Build & Debug" so you aren't prevented from running under the debugger by unit test failures during build.)
-- Chris
|