MyAppUITest.swift
...
override func setUp() {
super.setUp()
let app = XCUIApplication()
app.launchArguments.append("ui-testing")
app.launch()
}
...
MyAppDelegate.swift
...
func setupModel() -> Model {
let uiTesting = NSProcessInfo.processInfo().arguments.contains("ui-testing")
let model = uiTesting ? StubModel() : NetworkModel()
return model
}
...
MyAppUITest.swift
...
override func setUp() {
super.setUp()
let app = XCUIApplication()
app.launchArguments.appendContentsOf(["-ui-testing","YES"])
app.launch()
}
...
MyAppDelegate.swift
...
func setupModel() -> Model {
let defaults = NSUserDefaults.standardUserDefaults()
let uiTesting = defaults.boolForKey("ui-testing")
let model = uiTesting ? StubModel() : NetworkModel()
return model
}
...