My name is Ron Lisle. You can learn more about me on my personal website.
I’ve created this website to focus entirely on iOS Unit Testing. I’m very passionate about unit testing, having previously spent years using Test Driven Development (TDD) on .NET and PHP projects professionally. And now I’m advocating for unit testing on iOS.
Diving into unit testing isn’t easy. Nor is it simple. The concepts are simple, but the actual execution tends to be much more difficult than suggested by many books and blog entries about it. Let me encourage you though. There is a steep learning curve to using unit tests, but once you get over that curve it becomes very easy to develop code using test driven development.
Adding unit tests to existing code tends to be a very frustrating experience. I remember how fired up I got after reading my first article about using automated unit testing frameworks, only to fall into frustration and disappointment upon trying to add unit tests to my existing code. Adding unit tests to code that was written without unit testing in mind is really, really hard! Better to write unit tests and code at the same time. Even better to write the unit tests before the code. This is referred to as Test Driven Development or TDD.
Switching to TDD is typically very uncomfortable. It requires that you really think about the problem that you are trying to solve before writing any code. I know that I am inclined to just start writing code in order to help me organize my thoughts about what the code should be doing. I’ve had to discipline myself to write unit tests to do this, instead of just diving into writing code. Let me encourage you with this. Writing tests instead of code is a much better way to help you think about what you want the code to do.
I began playing with iOS just for fun. I’ve been a professional programmer longer than I’d like to admit, and I have to say that programming an iPhone is just plain fun! So much power, such great development tools, all at a very low cost. And you can carry it wherever you go! I was quickly hooked.
iPhone apps can be created with very few lines of code. This is fun, but leads to writing unmaintainable code. One can throw a few lines of code together to create a starter app, then just keep adding a few lines here and there and watch the app grow into a completely unmanageable mess.
After doing this a few times, I decided to stop playing in iOS and to start using the software engineering practices I had learned and had been using professionally. I would never consider creating a software project without using an SCM. I’m not sure now why I had thought that it would be ok to not use unit tests. So I looked into the unit testing support available then for Xcode 3, and was a bit appalled. I had just assumed that since the NextStep based libraries were so well done, that the supporting testing frameworks would be also. But I dug in, did some experimenting and was able to figure out how to do at least simple unit testing using the integrated SenTestingKit.
Towards the end of 2010, I went from being an iOS hobbyist programmer to becoming a professional iOS contractor. Then in April of 2011 I joined Mutual Mobile, at that time a 2 year old mobile solutions company in Austin, TX. There I started evangelizing the use of unit tests. But the unit testing support in Xcode 3 was horrendous. Even worse was the scarcity of good information about how to unit test in Xcode. I spent a lot of time pouring over blog posts trying to sort things out. Apple’s documentation was of little help.
Things became both better and worse when Xcode 4 was released. Some nice enhancements were made to the unit testing support, and the documentation was improved somewhat, but there was still a lot that wasn’t explained by the documentation. Further, the differences from Xcode 3 were substantial, making nearly all of the existing information on the blogs incorrect. I had to do a lot of experimentation to get even a hazy picture of how unit testing worked in Xcode 4.
In late 2011 I approached lynda.com about creating an iOS unit testing course, and it was released in April 2012. About the same time, Graham Lee released his book on Test Driven iOS Development. So now there are at least a couple good resources available to help teach iOS unit testing. But we still have a long way to go.