Tag: octest

为什么unit testing内部的代码不能findbundle资源?

我unit testing的一些代码需要加载一个资源文件。 它包含以下行: NSString *path = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"txt"]; 在应用程序中它运行得很好,但是当由unit testing框架pathForResource:运行时pathForResource:返回nil,这意味着它找不到foo.txt 。 我已经确定foo.txt包含在unit testing目标的Copy Bundle Resources构build阶段,所以为什么找不到这个文件呢?