我对Xcode4 4在iOS模拟器中运行应用程序测试的能力感到困惑。
一方面,苹果自己的文档显示,应用程序测试可以在模拟器中运行。另一方面,我在这里读过论坛,似乎大多数人都发现,应用程序测试只能在设备上运行。
如果后者是正确的,请包括一个链接,以证明这一点。我什么都没找到。
无论如何,来自iOS应用程序开发工作流指南:单元测试应用程序
Listing 6-2 Transcript of an iOS Simulator-based application unit-test run
而且还
Note: Although Xcode can run logic and application unit tests in simulators, Xcode cannot run logic unit tests on devices. Therefore, if you include and have active both types of unit tests in a scheme, you will not be able to use that scheme to run unit tests on devices.
问题是模拟器不提供对UIApplicationDelegate的访问。下面是一个示例测试来演示:
- (void) testAppDelegate { id yourApplicationDelegate = [[UIApplication sharedApplication] delegate]; STAssertNotNil(yourApplicationDelegate, @"UIApplication failed to find the AppDelegate"); }
这个测试在我的项目中失败了。顺便说一句,我的逻辑测试运行良好。
发布于 2011-11-06 20:49:58
我的错,我说得太早了。我试过这个解决方案,它很管用。换句话说,我现在能够在iOS模拟器中运行逻辑测试和应用测试。
确保在测试目标的生成设置中同时设置bundle loader和test host参数。
https://stackoverflow.com/questions/8017505
复制相似问题