2012-02-12 89 views
0

我的问题是,我正在尝试从SenTesking Kit中测试一些东西。无法从SenTeskingKit访问故事板

-(void)testStoryboard { 
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
    STAssertNotNil(storyBoard, @"Can't access the storyboard"); 
} 

我还添加了UIMainStoryboardFile到DemoTests.plist但我得到这样那样的错误:

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

我想你会需要更具体对这里的包。当你通过nil这样的软件包时,这意味着“使用主包”,但是如果我正确记得运行测试时的主包是测试用具应用程序包而不是代码。我认为您需要确保故事板作为资源包含在测试目标中,然后您需要在测试中明确指定故事板资源将从测试目标包加载,而不是主包。

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

+0

感谢您的回答,我已经通过一些资源检查了这一个。我发现我应该以某种方式明确指定如何使用相同的包。任何想法,我应该把而不是零? – 2012-02-12 14:24:29

+0

@Dmitry Preobrazhenskiy:更新了这个答案。对于i386硬件架构 – ipmcc 2012-02-12 15:07:27

+0

错误未定义的符号: “_OBJC_CLASS _ $ _ DemoAppDelegate”,从引用: objc级,裁判在DemoTests.o LD:符号(S)没有找到i386硬件架构 铛:错误:连接命令,退出失败代码1(使用-v来查看调用)storyBoard = [UIStoryboard storyboardWithName:@“MainStoryboard”bundle:[NSBundle bundleForClass:[DemoAppDelegate class]]]; – 2012-02-12 15:40:20