问题
my question is that I am trying to test some stuff from SenTesking Kit.
-(void)testStoryboard {
storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
STAssertNotNil(storyBoard, @"Can't access the storyboard");
}
I have also added the UIMainStoryboardFile to the DemoTests.plist but am getting this kind of error:
error: testStoryboard (DemoTests) failed: Could not find a storyboard named 'MainStoryboard'
in bundle
NSBundle</Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/usr/bin> (loaded)
回答1:
I think you're going to need to be more specific about the bundle here. When you pass nil
for a bundle like this, it means "use the main bundle", but if I recall correctly the main bundle when running tests will be the test harness applications bundle and not your code. I think you need to make sure that the storyboard is being included as a resource in the testing target and then you need to explicitly specify in the test that the storyboard resource is to be loaded from the your test target bundle and not the main bundle.
EDIT: Typically a good way to do this might be to pass [NSBundle bundleForClass: [MyClassThatIKnowIsInTheRightBundle class]]
.
来源:https://stackoverflow.com/questions/9248913/cant-access-the-storyboard-from-senteskingkit