【问题标题】:Xcode 4: Application Tests in iOS SimulatorXcode 4:iOS 模拟器中的应用程序测试
【发布时间】: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


    【解决方案1】:

    我的错,我说得太早了。我试过this solution 并且有效。换句话说,我现在可以在 iOS 模拟器中运行逻辑测试和应用程序测试。

    请务必在构建设置中为您的测试目标设置 bundle loadertest host 参数。

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-26
      • 1970-01-01
      • 2018-01-21
      • 2023-03-07
      • 2015-10-29
      • 2015-04-12
      相关资源
      最近更新 更多