1 xcode automated-tests ios9 xcode-ui-testing
我一直在Xcode中使用新的XCUITest。现在,我要制作一个测试用例,该用例将执行某些特定步骤,终止该应用程序并重新打开它。我知道这在仪器中是不可能的,所以我想知道是否可以用XCUITest做到这一点。
如果您使用的是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.
}
}
Run Code Online (Sandbox Code Playgroud)