Test-Driven Development and Continuous Integration for iPhone
I’m working on an iOS project and would like to use test-driven development and continuous integration. I don’t believe that it’s unreasonable to ask for a development environment to support TDD and CI these days and there are some encouraging signs such as the bundling of OCUnit with XCode. I’m documenting this so that other people can collaborate and help to fill in the blanks or show us an even better way to do it:
Goal: As a developer I want to build the software completely automatically from the command-line and have that automated process fail if any test in the project fails so that I can have some confidence in the app I’m building.
I followed the instructions on the Apple Developer website
I managed to build, run and debug a separate target in the application’s xcode project that contained all the tests.
I found these command-line options for cleaning the project and building the unit tests:
xcodebuild -target UnitTests clean build
UnitTestswas the name of the “target” I created containing the tests.
- I needed to issue that command-line from the root directory of xcode project.
The important remaining question: How do I run the tests in the simulator from the command-line and act on the results?
Promising scripts found (but haven’t managed to get them working in my environment)
As part of the standard iOS SDK installed under
/Developer you have these scripts:
/Developer/Tools/RunPlatformUnitTestsApple tool for xcode config calling otest (seems to need lots of configuration)
/Developer/Tools/otestthe raw test runner
These were found by investigating http://cocoawithlove.com/2009/12/sample-iphone-application-with-complete.html
Build and test resources to investigate
- http://archimage.posterous.com/setting-up-a-ci-environment-for-iphoneipad-de (looks useful - hudson and simulator launching mentioned)
Acceptance test-driven development (Nice to have)
Misc. to be investigated
If you can suggest ideas or a better way of going about this please get in touch.