0

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

-(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)
4

1 回答 1

1

我认为您需要在这里更具体地了解捆绑包。当你通过nil这样的包时,它意味着“使用主包”,但如果我没记错的话,运行测试时的主包将是测试工具应用程序包,而不是你的代码。我认为您需要确保情节提要作为资源包含在测试目标中,然后您需要在测试中明确指定情节提要资源将从您的测试目标包而不是主包中加载。

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

于 2012-02-12T13:47:18.930 回答