Reputation: 21
I've been using the new XCUITest in Xcode. Right now I am about to make a test case that will do some certain procedure, terminates the app and reopen it. I know this is impossible in instrument so I wonder if it is possible to do it with XCUITest.
Upvotes: 2
Views: 3130
Reputation: 407
If you are using swift and 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.
}
}
Upvotes: 6
Reputation: 1203
The XCUIApplication class contains launch and terminate methods that you can call to close and reopen the application.
I'm unsure of the swift syntax but you can do the following in Objective-C:
XCUIApplication *app = [[XCUIApplication alloc] init];
app.terminate;
app.launch;
Upvotes: 0