2011-11-05 96 views
3

我對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"); }

此測試失敗。順便說一下,我的邏輯測試運行良好。

回答

3

我的不好,我說得太快了。我試過this solution,它的工作原理。換句話說,我現在可以在iOS模擬器中運行邏輯測試和應用程序測試。

請務必在測試目標的Build Settings中設置bundle loadertest host參數。

相關問題