The Wite Box Project is an open source unit-testing framework designed and implemented specifically for iPhone. I started this project in response to the existing solution, the SenTesting Framework, which I find below par for a variety of reasons.
Here are some of the features of Wite Box and how I believe they improve on what exists today:
Visual Results in a Native iPhone Application
As a devout TDD developer, I have become somewhat addicted to the "green bar." Unit-testing devotees know what I mean. To see that beautiful green bar, perhaps after a few iterations of the nasty red bar, to soothe you, to tell you it's OK, to confirm all your beliefs that your code is sound and correct. Oh, what a feeling. But the SenTesting Framework took that away from me. My only positive feelings come from a *lack* of build errors (which are really unit test errors). It's just not enough for me. The results are displayed in a native iPhone application. That's right, this system was build for iPhone development specifically. As the iPhone SDK grows, so can Wite Box right along with it.
Navigable Test Results
The most annoying thing I find about the SenTesting Framework is that unless you read the compilation console -- and who on Earth wants to keep that thing open?? -- you can't really know if your unit tests were run at all. This is a noticeable omission as it's a very common mistake by developers to think their tests are being run when they are not. This becomes a problem when you are getting success back, and you assume your unit tests are good, when in fact they never ran at all!
Wite Box displays all your test cases, and unit tests, in a navigable UITableView. The successful tests are green and the failed tests are red. Failed tests can even show you what went wrong. It's very easy to see the results of every test you've added, but most importantly you will easily know which tests have run in the first place!
Expanded Hooks
I've always wanted wanted more hooks to add to my test case. xUnit has historically included setUp() and tearDown(), methods that run at the beginning and end of every test. Sometimes, though, I want a little more control. Wite Box provides it. There is still setUp and tearDown, but these now are run before and after the test case in its entirety. Now, you can set up just one database connection, or open the contents of just one file. Once. In addition, there is setUpTest:(SEL) and tearDownTest:(SEL) which not only run before and after each unit test, but pass along the method that will get called in case you want to have more custom initializations. Test cases also let you define a (BOOL)isEnabled method so you can enable and disable test cases programmatically.
Easy Setup
One good thing about the SenTesting Framework is how easy it is to set up. Aside from the fact that test cases fail if you haven't added any yet, it's pretty easy to add test cases and have them run. Wite Box preserves that ease. The setup procedure takes just a minute for Wite Box, and by the end of it you have a running application that runs your unit tests and gives you all your results in a clear display. Don't worry about messy setups or broken code!
What's Coming
The Wite Box Project is a work in progress. Currently, at v0.92, it works for synchronous test cases and all the hooks are there. Soon, however, it will be expanded for asynchronous support and an expanded set of asserts, including Hamcrest.Getting Started
If you're ready to get started, head over to The Wite Box Project and check out the Wiki documents on Setting Up Wite Box and then Writing Unit Tests. We hope you enjoy our unit testing for iPhone!!!










