Thursday, October 13, 2011

Using Kiwi with UI Components on iOS

Trying to get unit testing with Kiwi while being able to use UIKit components was beginning to get frustrating.  The issue is that the tests would crash whenever trying to initialize any UIView components such as UILabel, UITextField, etc.  Well, to some the answer may be obvious, but to relative newbies to iOS like myself it was not.  In order to create instances of UI components you need an actual application running(duh?).  When setting up a unit test bundle in Xcode you can either set it up with or without an app that hosts the tests.  Logic tests are done in test bundles that don't have a host app and application tests are done in test bundles that have a host app.  So for those struggling to create tests that rely on UI components, here's how you do it.


Thanks to Allen Ding the creator of Kiwi for his help and pointing me in the right direction.  Happy testing!

No comments:

Post a Comment