Unit testing initialization code

Joined
Aug 27, 2011
Messages
8
Reaction score
1
Points
3
I am trying to write an appliction for the iPad using Xcode 4.3 and a 3rd party game engine. I also want to write unit test for the components in my application.

Currently I'm trying to write a unit test for an object performs some operations during initialization of the application. Basically the object will obtain an instance of another object (provided via a mock in the unit test) and does something with that other object.

The problem right now is that the code exists in the initialization phase of the application. This means that before the unit test can actually run the application itself gets launched and tries to initialize itself. The object under test tried to obtain the other object it needs. This fails because the functionality has been written yet (I'm still trying to write the tests for it) and the application dies before the test can run.

The whole fact that the application even tries to run during the unit test seems totally screwy from the way unit testing is actually done.

How is someone supposed to unit test code like this?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top