07 June 2011

Why Kiwi for iOS testing

I just decided on Kiwi for a project rather than OCMock + OCUnit. These are Kiwi's selling points for me:

  1. Stubbing class methods is simpler. With OCMock, I needed to create a special class (one per project - similar to this) to do method swizzling. No such problem with Kiwi - just [MyClass stub:@selector(doFoo) andReturn:myBar];
  2. Mock failures with Kiwi show up on the line that failed in Xcode (they showed up in strange places with OCMock).
  3. Kiwi's test failures produce descriptive, unambiguous error messages (as opposed to the not-so-helpful messages from OCMock & OCUnit).
  4. Syntax. should, equal, stub, mock, and more (rather than STAssertEqualObjects and other not-so-easy-to-read macros & methods). Check out the first code sample on the Setup page to decide for yourself.
  5. No need to [mock verify].
Update: The latest version of Kiwi does support debugging in blocks, so the Blocks Alternative is no longer necessary for debugging. I've removed the outdated information from this post.