Skip to content

Instantly share code, notes, and snippets.

func testNSUserDefaultsAndKeychain() {
app.userDefaultsSetObject(0, forKey: "view_count")
// interact with UI
app.buttons["Button"].tap()
let counter = app.userDefaultsObjectForKey("view_count")?.integerValue!
XCTAssert(counter == 1)
}
func testStubbing() {
// setup your stub
let stubId = app.stubRequestsWithRegex("(.*)apple(.*)", returnJsonDictionary: ["key": "value"], returnCode: 200, responseTime: SBTUITunnelStubsDownloadSpeed3G)
// execute your test here. Expect requests to `(.*)apple(.*)` to return a JSON
...
// you can optionally remove the stub
app.stubRequestsRemoveWithId(stubId!)
@tcamin
tcamin / SetupTest.swift
Last active June 29, 2016 12:56
SBTUITestTunnel XCTestCase Setup
import XCTest
import SBTUITestTunnel
class TestTunnelDemoUITests: XCTestCase {
var app: SBTUITunneledApplication!
override func setUp() {
super.setUp()
continueAfterFailure = true
@tcamin
tcamin / Podfile
Created June 29, 2016 09:23
SBTUITestTunnel Setup
use_frameworks!
target 'APP_TARGET' do
pod 'SBTUITestTunnel/Server'
end
target 'UITESTS_TARGET' do
pod 'SBTUITestTunnel/Client'
end
@tcamin
tcamin / AppDelegate.swift
Last active June 29, 2016 09:28
SBTUITestTunnel Setup
import UIKit
import SBTUITestTunnel
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
override class func initialize() {
SBTUITestTunnelServer.takeOff()
super.initialize()