Chapter 20. Unit Testing
WHAT'S IN THIS CHAPTER?
Learning how unit tests work
Adding unit tests to your Objective-C project
Configuring unit tests for an iPhone app
Adding unit tests to your C or C++ project
Unit testing is a way of validating the run time behavior of your code at build time. In other words, you can test and verify the functionality of individual modules before you assemble them into a working application.
In addition to writing your application's classes, you also write one or more unit tests that exercise those classes and verify that they perform as expected. These tests are not part of your application and live in a separate unit test bundle. You can elect to have these tests performed on your code whenever you build your product, ensuring not only that your code compiles and links but that it behaves correctly as well.
Unit testing is a fundamental part of Test Driven Development (TDD), a development philosophy popularized by the Extreme Programming movement. In TDD, you develop the test for your function or class first, and then write your function to meet the expectations of the test. In essence, this is what rigorous designers have done for years. They first develop a detailed specification of exactly what a function should do, write the function, and then verify that the function behaves as designed. The quantum leap provided by unit tests is that the "specification" is now an automated test that verifies the design goals of the code rather than a paper description ...
Get Professional Xcode® 3 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.