Writing Unit tests for Cocoa

I realized something interesting today.

I use unit testing to (hopefully) improve the quality of my code.

With Java I use JUnit. With native Mac stuff I use OCUnit.

One really clever thing about OCUnit that I realized today is that if you have several SenTestCase subclasses, each with multiple tests in it, you can put all of them into one XCode target and OCUnit will automatically run them as suites in one test run. This means that you get a summary of all of the tests at the end.

Previously I had a separate XCode target for each test case, where each test case class reported its results separately, which isn’t nearly as good.

This entry was posted in Macintosh, Writing Software and tagged , , , , . Bookmark the permalink.

Leave a Reply