Well, NSZombieEnabled
and friends are environment variables, which means they have to be run on an executable. The default setup for a unit testing bundle is for the tests to be run during the build process, and not during execution.
So the way to fix this is to make it so that your tests don't run during the build phase, but instead run them as part of an executable.
Here's how I do that:
- Inside your Unit Test bundle target, remove the "Run Script" build phase. It's that step that executes the tests after compiling them.
- From the Project menu, choose "New Custom Executable..." and name it something meaningful, like "otest"
- Make the executable path to be the
otest
binary, which should be located at /Developer/Tools/otest
- Set the following environment variables on the otest executable:
DYLD_FRAMEWORK_PATH
=> {UnitTest.bundle}/Contents/Frameworks
DYLD_LIBRARY_PATH
=> {UnitTest.bundle}/Contents/Frameworks
- Set the following program arguments on the otest executable:
-SenTest All
(this will run all of the unit tests)
{UnitTest.bundle}
You can now select your unit test bundle as the active target, and the otest executable as the active executable, and then build and debug. This will let you set breakpoints, set other environment variables (like NSZombieEnabled
), and so on.
If you only want to debug a certain suite or specific unit test, you can change the -SenTest All
argument to -SenTest MyUnitTestSuite
or -SenTest MyUnitTestSuite/myUnitTestMethod
.