2015-09-23 62 views
1

我一直在Xcode中使用新的XCUITest。 現在我正在做一個測試用例,它將執行一些特定的過程,終止應用程序並重新打開它。 我知道這在儀器中是不可能的,所以我想知道是否可以用XCUITest來做到這一點。使用XCUITest終止並重新打開應用程序iOS9

回答

0

XCUIApplication類包含可調用以關閉並重新打開應用程序的啓動和終止方法。

我不確定迅速語法,但你可以做到在Objective-C如下:

XCUIApplication *app = [[XCUIApplication alloc] init]; 

app.terminate; 

app.launch; 
3

如果您使用SWIFT和XCTestCase

import XCTest 

class SomeTests: XCTestCase { 

    func testSomeFunctionality() { 
     let app = XCUIApplication() 
     // by setting launch arguments you can set your app to "test mode" 
     app.launchArguments = ["arg1", "arg2"] 
     app.launch() 

     // .... code that runs the desired procedure. 

     app.terminate() 

     // At this point you can set different launch args if you need the app to be in a different mode 
     app.launchArguments = ["arg1", "arg2"] 
     app.launch() 

     // .... code that finishes up the test. 
    } 

} 
相關問題