【发布时间】:2011-11-05 01:26:31
【问题描述】:
我对 Xcode4 在 iOS 模拟器中运行应用程序测试的能力感到困惑。
一方面,Apple 自己的文档说应用程序测试可以在模拟器中运行。另一方面,我已经阅读了这里的论坛,似乎大多数人发现并非如此,应用程序测试只能在设备上运行。
如果后者是真的,请提供一个链接来记录这一点。我什么都没找到。
无论如何,来自iOS App Development Workflow Guide:Unit Testing Applications:
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"); }
此测试在我的项目中失败。顺便说一句,我的逻辑测试运行良好。
【问题讨论】:
标签: unit-testing xcode4