Reputation: 2424
When i run unit tests it fails on loading external resources (images) with the same error as if they don't exist. In xcode i have added the resources to the unit test target. I don't know what to try next.
I am using the Cocos2d framework, I try to load the following code within a unit test
AtlasSpriteManager *at = [AtlasSpriteManager spriteManagerWithFile:@"player2.png" capacity:50];
It seems this actually calls
UIImage imageWithContentsOfFile
which returns nil.
The actual code that throws the error looks like
image = [uiImage CGImage];
if(image == NULL) {
[self release];
NSLog(@"Image is Null");
return nil;
}
It seems that the images required are not copied over to the Application Support directory before the unit tests run, only after a successful pass. I am not sure if this is the problem, but if it is is there a way to change the build order so the images are copied first and the unit tests can find them?
Upvotes: 2
Views: 431
Reputation: 243156
The resources most likely aren't getting included into the target. So before you have your Run Script phase of your test bundle, make sure you have a "Copy Resources" phase that copies the resources into the test bundle that the tests will need.
Upvotes: 1