Last Updated: December 26, 2018
· modocache

iOS Integration Testing: KIF or bwoken?


As of Instruments 4.2 (bundled with Xcode 4.2, Oct 2011), Apple provides an "Automation" instrument, which allows you to write test scripts in JavaScript which interact with a device running your application. Overall, however, the interface is very unwieldy, a downside which is remedied in part by bwoken. bwoken allows you to run your integration tests with a simple rake test command. Setup is also fairly simple--just import bwoken tasks in an otherwise empty Rakefile, then run rake bwoken:init. Easy as pie!

Actually writing the tests is much more of a pain, though. The API for accessing UI elements in JS takes some getting used to, and I experienced problems connecting with the simulator when running tests--sometimes the simulator would never launch, or hang suspended mid-test. The JS itself isn't very semantic, either. You can jasmine-iphone to make your tests read better, but I found setting it all up to be a chore.


The alternative to bwoken is KIF. Like bwoken, it uses accessibility elements, but it does so using unofficial APIs (not a problem for submission to the App Store, as long as you package them separately). KIF's been around for a while, and seems much more stable. You can also write all your tests in Xcode using Objective-C, so I found I didn't have to switch between editors as often as I did using bwoken. Tests are run via Xcode as well, so problems with finding a device don't seem to occur very often, if at all. Setup is also pretty straightforward, thanks to the KIF README and CocoaPods.

I've had experience using KIF in releasing a large-scale application, and it did not disappoint. bwoken seems like the more legit choice, as it's just a wrapper around an official testing API, but due to reliability issues I think I'll stick to KIF for now.

For information on testing solutions besides the two above, check out this awesome post on Stack Overflow.