Do I need special libraries for this, or can I just create a huge class that trys to instantiate every object of my project and test all the methods in there? How's that done in theory?
Googling "unit testing iPhone" gives this excellent link as the first hit:
To sum up, Google Toolbox provides a good infrastructure for unit testing on iPhone.
If you're targeting iPhone OS 2.2 or later, you can use the version of OCUnit that's bundled with Xcode. There's a good blog article by Kailoa Kadano about this on Mobile Orchard. OCUnit is a unit testing framework that's similar to the well known JUnit framework from the Java world.
You can always do "poor man's unit testing" by creating a simple test program that uses the assert()
macro in the C header assert.h
or the NSAssert()
macros in Cocoa/Cocoa-touch. That's not a horrible way to get started doing unit testing, but I'd really recommend looking at OCUnit or another unit testing framework eventually.
Which ever way you structure your unit tests, you'll want to create a separate target in your Xcode project to build and run the tests.