Resetting NSUserDefaults in UI Testing
- Add "UI-Testing" to
launchArguments
before launching the app under test - On launch, check for the argument in
AppDelegate.swift
- If it exists remove everything for the app's domain from
NSUserDefaults
launchArguments
before launching the app under testAppDelegate.swift
NSUserDefaults
. |
import CoreLocation | |
struct AddressFormatter { | |
private let placemark: Placemarkable | |
init(placemark: Placemarkable) { | |
self.placemark = placemark | |
} | |
func formattedAddress() -> String { |
. |
import XCTest | |
class TestCase: XCTestCase { | |
let app = XCUIApplication() | |
override func setUp() { | |
super.setUp() | |
continueAfterFailure = false | |
app.launchArguments = ["UI-Testing"] |
//: Playground - noun: a place where people can play | |
struct Option { | |
var id: UInt | |
var name: String | |
} | |
func combine(options: [Option]) -> [UInt: String] { | |
var combinedOptions = [UInt: String]() | |
for option in options { |
//: Playground - noun: a place where people can play | |
enum Error: ErrorType { | |
case ParsingError | |
} | |
struct Person { | |
let name: String | |
let age: Int |
protocol URLSessionDataTaskProtocol { | |
func resume() | |
} | |
extension NSURLSessionDataTask: URLSessionDataTaskProtocol { } |
import XCTest | |
class UITests: XCTestCase { | |
let app = XCUIApplication() | |
override func setUp() { | |
super.setUp() | |
continueAfterFailure = false | |
app.launch() | |
} |