Daily Archives: April 8, 2013

Setting up for Unit Testing

In my last post I talked about how to setup for Code Coverage and made a reference to unit testing. In this article I wanted to share my experience with setting up to run unit testing.

A great place to start is the Apple document Xcode Unit Testing Guide.

Setup target and initial test suite

Choose File > New > Target …
In the iOS section, select Other, then select the Cocoa Touch Unit Testing Bundle template.

Cocoa Touch Unit Testing Bundle template

Since my app is called ContactsOnline, I’ll name my product (new target) ContactsOnlineBasicUnitTests.

This creates a test suite by the same name ContactsOnlineBasicUnitTests.m, within a group called ContactsOnlineBasicUnitTests.

Unit-test targets define one or more test suites.

Continue reading

Setting up and using Code Coverage

My background includes many years of Verification work on complex computer and graphics chips, so I was happy to learn that Xcode had some support for testing and code coverage.   Code coverage is very useful as a guide to developing tests to let you see what portions of your code have been exercised.

The following example code coverage results are displayed using the tool CoverStory.   They show what percentage of various classes have been exercised in the left pane, along with details about which lines in a particular file have not been covered in the right pane (highlighted in red).

Code Coverage Display 2

Continue reading