On Mar 10, 2008, at 6:57 PM, William Hunt wrote:
On Mar 10, 2008, at 6:29 PM, Chris Hanson wrote:
On Mar 10, 2008, at 4:44 PM, William Hunt wrote:
When I call:

NSLog( @"bundlePath: %@", [[NSBundle mainBundle] bundlePath] );


I get:

2008-03-10 16:41:18.565 otest[3819:80f] bundlePath: /Developer/Tools

This is expected behavior if your unit tests are being run by otest. If you instead inject your tests into your application, then its main bundle will be returned instead (because the tests are actually run inside the application).


Ok, so it's the expected behavior. Phooey! I then have two questions:

1) How do I "inject [my] tests into [my] application?"

Set the "Test Host" build setting in your test bundle target to the path of the executable (not just the .app wrapper) you want to inject your tests into.

Then tests will be run by running your application with a special library inserted into it, which will in turn load your test bundle and run its contents, instead of by running them via otest.

2) Can I modify the ocunit target somehow so that the Bundle is where I'd expect it to be?

No, this isn't how bundles work. +[NSBundle mainBundle] should always refer to the bundle for the executable that is actually running, not elsewhere. If you follow the steps for #1 above you'll be fine.

I have more about this on my weblog under "Unit Testing Cocoa Applications" at <http://chanson.livejournal.com/120263.html>, and in other posts under the "unit testing" tag.

  -- Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to