When starting an Xcode Cocoa Project you should have a testing project that you include. It’s a simple check box on the project creation dialogs.
If for some reason you inherit a project that doesn’t have unit tests, tests, or anything of the sort and need to add a testing project follow these steps. With the project open add a new target as shown below.
Add a Cocoa Unit Testing Bundle.
Set the appropriate parameters for your project. Be sure to select the project from the drop down.
Once finished adding the testing target, edit the schema. The project will have an additional schema. I personally like to keep them rolled together, so delete the “*Tests” schema and just make sure that the Tests section has the right target listed.
If it isn’t listed, as shown in the above dialog, click the + to add the tests project. Select it in the target dialog as shown below.
Once all that is done then the tests can be executed from the Product -> Test menu option or the shortcut key combo of ⌘U. With the default code that is added to the target project, you’ll end up with one failing test.
Now write tests!