Technique for de-coupling Application Delegate and testing

76 views
Skip to first unread message

Nick Bonatsakis

unread,
Dec 5, 2009, 12:52:58 AM12/5/09
to GHUnit
Hi All,

I've been messing around with GHUnit, it is great. The first major
problem/question I've run into is around application delegates.
Typically, most iPhone apps will rely on the application delegate for
some operations, in my case, for obtaining Core Data managed contexts
and associated objects. If for example, I would like to test a view
controller that obtains these references internally via the
application delegate, I cannot test in GHUnit because it is using it's
own GHUnit app delegate. Are there any common techniques for removing
any dependencies to the app delegate, or conversely, is there a way to
get a test class to be run using the default app delegate as an
application level test?

Thanks

gabe

unread,
Dec 8, 2009, 5:49:04 PM12/8/09
to GHUnit
Yeah, one technique that I use is to extend the:

@interface MyTestApplicationDelegate : GHUnitIPhoneAppDelegate {
}
@end

Then in GHUnitIPhoneTestMain.m:

retVal = UIApplicationMain(argc, argv, nil,
@"MyTestApplicationDelegate");

I will look into seeing if I can make this easier, or remove the
dependency, but this should work in the meantime.

Hua-Ying Ling

unread,
Dec 9, 2009, 6:48:29 PM12/9/09
to ghu...@googlegroups.com
I just wanted to vote for this feature... I also do work in my app
delegate. This temporary solution would work but one down side is I
would have to link the debug library into my real executable.

Thanks!
Hua-Ying
> --
>
> You received this message because you are subscribed to the Google Groups "GHUnit" group.
> To post to this group, send email to ghu...@googlegroups.com.
> To unsubscribe from this group, send email to ghunit+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ghunit?hl=en.
>
>
>
Reply all
Reply to author
Forward
0 new messages