【发布时间】:2013-04-08 17:39:38
【问题描述】:
为了快速测试某些内容,我在我的应用程序包中添加了一个测试文件,并使用 NSBundle:pathForResource 将其加载到委托中。这行得通。
但是现在我刚刚创建了一个单元测试类型的目标并将文件和代码添加到这个新目标中,但无法加载它。
我已使用 Copy Bundle Resources 将文件添加到测试目标,这是加载它的完整代码:
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *xmlFilePath = [mainBundle pathForResource:@"TestServerResponse" ofType:@"xml"];
STAssertNotNil(xmlFilePath, @"Unable to open file TestServerResponse.xml")
我不知道为什么当它是 app bundle 目标的一部分时我可以加载它,但现在我已将它移到它不会加载的测试包中。
【问题讨论】:
标签: iphone ios unit-testing nsbundle