Xcode 4: Unit Testing Support
Developers doing test-driven development with the Cocoa and Cocoa Touch frameworks will like the improved support Xcode 4 has for unit testing. When you create a project that uses the Cocoa or Cocoa Touch frameworks, such as a Cocoa or iPhone application, Xcode gives you the option to add a unit testing bundle to the project.

When you select the Include Unit Tests checkbox, Xcode adds a unit testing bundle and a unit testing class to the project. Xcode also sets the Bundle Loader and Test Host build settings for the unit testing target and creates a target dependency so you can automatically run the unit tests.
Another change Apple made to unit testing in Xcode 4 is adding the Test After Build build setting. When you set the Test After Build build setting to YES, Xcode runs your unit tests after building the unit testing target. Choose Product > Build For > Build For Testing to build the unit testing target. The test results appear in the build results window. Read my Opening the Build Results Window post for more information on opening the build results window. If Test After Build is set to NO, you must run the tests by choosing Product > Test. Open the log navigator to view the test results. I found unit testing works better when setting Test After Build to YES.
If you open the scheme editor (use the Scheme pop-up menu in the project window toolbar), you can specify what tests are run as well as run scripts before and after running the tests. Xcode initially is set to run all tests.