Can't Access the storyboard from SenTeskingKit

…衆ロ難τιáo~ 提交于 2020-01-03 04:32:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!