Xcode 4:iOS模拟器中的应用程序测试
我对Xcode4在iOS模拟器中运行应用程序测试的能力感到困惑。Xcode 4:iOS模拟器中的应用程序测试
一方面,苹果自己的文档说应用程序测试可以在模拟器中运行。另一方面,我已阅读了这里的论坛,似乎大多数人都发现,应用程序测试只能在设备上运行。
如果后者为真,请包含一个链接来记录此。我一直无法找到任何东西。
不管怎么说,从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"); }
此测试失败。顺便说一下,我的逻辑测试运行良好。
我的不好,我说得太快了。我试过this solution,它的工作原理。换句话说,我现在可以在iOS模拟器中运行逻辑测试和应用程序测试。
请务必在测试目标的Build Settings中设置bundle loader
和test host
参数。