Important: This is a preliminary document. Although it has been reviewed for technical accuracy, it is not final. Apple Computer is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented according to this document should be tested with final operating system software and final documentation. For information about updates to this and other developer documentation, you can check the ADC Reference Library Revision List. To receive notification of documentation updates, you can sign up for ADC's free Online Program and receive the weekly Apple Developer Connection News email newsletter. (See http://developer.apple.com/membership for more details about the Online Program.)
It is a familiar scenario to many developers. Major development is complete. The application has been tested. The team is fairly confident about the stability of the code. Then someone introduces that one last feature that breaks several seemingly unrelated features. Somehow, the new code has changed a fundamental assumption about the behavior of a code module and that change has now broken other modules. How do you validate your code in a way that will prevent this scenario from happening again? One way is through unit testing.
By adding appropriate unit tests to your projects, each engineer can verify that newly introduced code does not break any existing behavior. A unit test is simply a piece of code that exercises some part of your application. The unit test provides a specific input and expects your code to return a specific output. If your code returns an unexpected value, the unit test reports the discrepancy.
Third-party unit testing modules have been available for Xcode for some time. In addition, Xcode 2.1 now integrates some modules directly into the project environment. These modules provide the basic testing harness needed to build automated and repeatable test suites. This document shows you how to incorporate unit tests into your Xcode projects and also offers tips and guidance on how to get the most out of your tests in Mac OS X.
This document includes the following article:
“Adding Unit Tests to Your Projects” shows you how to add unit testing capabilities to your Xcode projects.
“Unit Test Guidelines” provides some guidance on how to write unit tests effectively.
Last updated: 2008-05-02