Database Reference
In-Depth Information
Unit Testing iOS Applications
Creating unit tests is probably the most straightforward part of iOS testing, because
OCUnit has been a part of XCode for a long time (so it's pretty well documented). With
recent releases of XCode, things have been improved further, such as by running the
tests on the simulator rather than at compile time, which makes them easier to debug,
and offers up a powerful new alternative to the creaky UIAutomationTesting framework,
something I'll get to shortly.
Certain things had been broken, however—most notably the generation of code cov-
erage statistics using the gcov library. When iOS 4 went to using LLVM as the default
compiler, gcov was broken, but it has returned from the dead in iOS 5. I'll talk a bit
about gcov and CoverStory later in this section.
Setting Up an OCUnit Target
In any event, you get asked if you want to create a unit test target when you first create
a project. If you don't, you can add one later by doing a simple “Add Target” and
picking “Cocoa Touch Unit Testing Bundle” ( Figure 5-1 ).
Figure 5-1. Adding an OCUnit target to your project
 
Search WWH ::




Custom Search