我對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"); }
此測試失敗。順便說一下,我的邏輯測試運行良好。