Blog

How to Debug iPhone Unit Tests

[Updated the troubleshooting section 10/4/2009]

The unit tests are finally set up for the iPhone. You can start doing some Test Driven Development, but one is failing. I've read Apple's documentation, but how do I debug the blasted thing?

NSLog messages can be scattered throughout the code. Their output is sent to the console, but this is a pain. There must be a better way.

This is one area that needs to be improved in Xcode. There is not even documentation on how to debug unit tests.

Here's how to do it.

The following assumes that you have set up the unit tests using the templates in Xcode and follows along with Apple's example in their iPhone Development Guide. If you have not already set up your units test then the iPhone Development Guide is a good place to start. I am also using Xcode 3.2.

Three steps that need to be performed.

    1. Setup a target that contains the unit tests, but does not run them.

    2. Setup the otest executable to run the tests.

    3. Setup the otest environment so that otest can find your unit tests.

Hello World

What else should a geeky programmer's first post be?