
Unit testing
11 months ago
Why and how to do unit testing for Cocoa (Mac) applications using OCUnit, which comes with Xcode.
I'm not an iPhone developer, so please don't ask me about testing for iPhone applications. Instead, see this blog post by my friend Colin Barrett: iamthewalr.us/blog/2008/11/10/ocmock-and-the-iphone/
This video is based on a presentation I gave at the December 2008 meeting of CocoaHeads in Lake Forest, California. This version is corrected and expanded from the original.
I'm not an iPhone developer, so please don't ask me about testing for iPhone applications. Instead, see this blog post by my friend Colin Barrett: iamthewalr.us/blog/2008/11/10/ocmock-and-the-iphone/
This video is based on a presentation I gave at the December 2008 meeting of CocoaHeads in Lake Forest, California. This version is corrected and expanded from the original.
-
Vimeo: About / Blog / Developers / Jobs / Community Guidelines / Community Forums / Help Center / Site Map / Merchandise
/ Get Vimeo

Previous Week
My question about testing in Cocoa is how to test singletons. For example, how would I test that a main menu item successfully calls an action on a custom controller? I can't mock up the main menu because it is effectively part of the NSApp singleton -- which I can't use in my test cases...
Thanks again -- and I love Adium too!
You can load the main menu nib explicitly. Pass your own object as File's Owner—you may get a warning because it's not an NSApplication, but as long as it has all the necessary outlets (e.g., mainMenu), it should just work.
I have noticed that (I think) OCUnit runs your tests in parallel. This has made testing a little more tricky for me. Some of my code wasn't designed to run in parallel -- although now it is because of OCUnit. Added bonus I guess!