Xcode 4 includes unit tests by default, make sure that when you create a new project, you check the "Enable unit tests" option when you select the project name on the screen. This will create a new target called <YourProduct>Tests , i.e. If you named your project MarcosGame, it will create a target named MarcosGameTests . It will also create a new group of files called MarcosGameTests , where you must add your test files.
Whenever you create a class that you want to test, be sure to add it to the target audience (you get this option on the screen where you give your new class a name). Then you should also add the test file to your Tests group (through the new file route, select the Objective-C Test Case file) and make sure that you include it in the MarcosGameTests target, but not the main target (MarcosGame). Attach your tests here.
Write some tests, then when you are ready to run them, select "Test" in the "Product" menu, and all test failures will be displayed as build errors.
source share