无法从 SenTeskingKit 访问故事板 [英] Can't Access the storyboard from SenTeskingKit

查看:58
本文介绍了无法从 SenTeskingKit 访问故事板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我正在尝试从 SenTesking Kit 测试一些东西.

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");
}

我还将 UIMainStoryboardFile 添加到 DemoTests.plist 中,但出现此类错误:

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)

推荐答案

我认为您需要更具体地了解此处的捆绑包.当你为这样的包传递 nil 时,它意味着使用主包",但如果我没记错的话,运行测试时的主包将是测试工具应用程序包而不是你的代码.我认为您需要确保故事板作为资源包含在测试目标中,然后您需要在测试中明确指定故事板资源将从您的测试目标包而不是主包加载.

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.

通常这样做的一个好方法可能是通过 [NSBundle bundleForClass: [MyClassThatIKnowIsInTheRightBundle class]].

Typically a good way to do this might be to pass [NSBundle bundleForClass: [MyClassThatIKnowIsInTheRightBundle class]].

这篇关于无法从 SenTeskingKit 访问故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆