Automatically Running Unit Tests

One additional tip that I wanted to add to the post on Unit Testing with OCUnit. If you make the UnitTests target a dependent of the application target it will get run automatically each time you build the application target. The easiest way to create the dependency is to drag the UnitTests target onto the TheElements application target.

Alternatively right-click on the target (TheElements) and use Get Info to view the target settings. In the General build tab the top window shows the direct dependencies of the target. Click the + button and select the UnitTests target from the list of available targets (in this case there is only one).

Now whenever you build the target TheElements the UnitTests target also gets run without you having to remember to do it.