Really. I have tried. I have done it successfully but it was a bit of work.
There are a number of complications to set up a decent testing environment for iOS. I will describe which tools I choose and what I had to do to get everything running. I will not describe everything in detail but hopefully it will still give you a starting point.
All in all, I think that this should be (a lot) easier, even in this part of the C universe.
So what do I consider a decent testing environment?
I think at first we need support for unit tests and acceptance tests (in the agile meaning). Unit tests to get the low level stuff right (we can also use it for some integration testing) and acceptance tests to do some end-to-end testing.
Running all the tests manually is not a good idea anymore so I will run them on a continuous integration server, which will also take care of collecting code coverage.
My current collection of tools include XCode (xcodebuild, gcc, gcov) with iOS SDK, Google Toolbox for Mac, OCMock, OCHamcrest, Cucumber, Frank (includes UISpec) and Jenkins/Hudson (with gcovr for xml-ifying gcov).
All tools are free and all I had to do was to make them play together. A number of blogs provided helpful information. I will try to list them for reference.
There is a lot of stuff and to make it an easier read I split in into multiple articles. Here is the complete list:
- iOS: Setting Up a Test Environment is a Mess (that’s what your are reading now)
- iOS: Setting Up Basic Unit Testing (Google Toolbox for Mac)
- iOS: Setting Up Advanced Unit Testing (OCMock & OCHamcrest)
- iOS: Running Unit Tests with Code Coverage in Jenkins/Hudson (gcovr & Jenkins/Hudson)
- iOS: Setting Up Acceptance Testing (Cucumber & Frank)
- iOS: Running Cucumber/Frank with Code Coverage in Hudson (Frank & Jenkins/Hudson)
February 2011: Here is new article regarding setup of OCMock & OCHamcrest:
- iOS: Setting Up Advanced Unit Testing Take Two (OCMock & OCHamcrest)
Ok, let’s start with iOS: Setting Up Basic Unit Testing.