Test Driven Development with Objective C

18 Oct
2009

Threre’s no excuse to NOT use TDD even if you program in objective c.

OCUnit (SENTestingKit.framework) is the apple way of testcases (included in Xcode)
google-toolbox-for-mac has some additions for SenTestingKit providing UI unit testing, binding, log tracking and iPhone.

With iPhone SDK 3.0, Apple provides a demo application called ‘iPhoneUnitTests‘.
They show both logic and UI tests. Logic tests run at build time (CalcTests)
The UI tests only run with a real device, not in simulator. (CalculatorTests)

I don’t like it. SENTestingKit is cumbersome, you have no test gui, you have to work with those ocbundle files… it may not be bad, but it’s old awkward stuff. Why use it when there is something better?

Say hello to GHUnit by Gabriel Handford.

GHUnit is a test framework for Objective-C (Mac OS X 10.5 and iPhone 2.x/3.x). It can be used with SenTestingKit, GTM or by itself.

For example, your test cases will be run if they subclass any of the following:
GHTestCase, SenTestCase, GTMTestCase

In a future blog post I may explain mock objects in Objective-C via OCMock and OCHamcrest (matchers).

Related posts:

  1. Detect conflicting Objective C category methods
  2. iPhone development lectures
  3. iPhone Application Development Presentation

Comment Form

top

Switch to our mobile site