Quantcast
Channel: Vincent Gable's Blog » Unit Testing
Viewing all articles
Browse latest Browse all 3

Resources in Unit Tests and Other Frameworks

$
0
0

To load a resource inside a unit test or other bundle, do:

NSBundle *unitTestsBundle = [NSBundle bundleForClass:[self class]];
NSString *pathToResource = [unitTestsBundle pathForResource:name ofType:fileExtension];

[NSBundle mainBundle] points to the bundle for the current executable, so it’s handy in an application (where it will point to your .app bundle). But since unit tests are loaded into another program or test-harness to run, it’s not appropriate to use it in a unit test.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images