Appendix E. Unit Testing
In this appendix, we show you how to add unit tests to your project. By adding unit testing support, you'll be able to write tests for your methods. These tests will be added as a dependency on the building of your application. This will result in the tests being run before actually building your application.
In the following, we walk you through a step-by-step process for adding unit testing. We use a simple Employee
class for demonstration purposes.
Adding a Unit Test Target
In this section, we show you how to create a unit test target in your project. Later, we will make our main target dependent on this unit test target, thus making sure that the unit tests are executed before building our target.
Right-click on Targets node in Groups & Files. Select Add > New Target as shown in Figure E.1.
Figure E.1. Selecting Add New Target from the context menu.
Select Cocoa under the Mac OS X category. Scroll down and double-click on Unit Test Bundle as shown in Figure E.2.
Enter the name of the target, such as MyUnitTestBundle
, as shown in Figure E.3.
Figure E.2. Choosing Unit Test Bundle for the new target.
Figure E.3. Naming the Unit Test Bundle.
Adapting to Foundation
The target ...
Get iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.