Thursday, May 24, 2012

Unit test with NSBundle


When the unit test harness runs your code, your unit test bundle is NOT the main bundle. Your code is searching the wrong bundle. If you replace the above line with:
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"foo" ofType:@"txt"];
Then everything will be fine.

No comments: