Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Testing and Architecture

Swift Testing and Architecture

Danielle Tomlinson

September 11, 2015
Tweet

More Decks by Danielle Tomlinson

Other Decks in Programming

Transcript

  1. What? Test noun: A procedure intended to establish the quality,

    performance, or reliability of something, especially before it is taken into widespread use.
  2. XCTest // Contrived example test for a mythical add function

    func test_can_add_two_numbers() { // arrange let firstNumber = 1 let secondNumber = 1 let expectedResult = 2 // act let ! = add(firstNumber, secondNumber) // assert XCTAssertEqual(!, expectedResult) }
  3. OHHTTPStubs OHHTTPStubs.stubRequestsPassingTest({$0.URL!.host == "mywebservice.com"}) { _ in // Stub it

    with our "wsresponse.json" stub file (which is in same bundle as self) let fixture = OHPathForFile("wsresponse.json", self.dynamicType) return OHHTTPStubsResponse(fileAtPath: fixture!, statusCode: 200, headers: ["Content-Type":"application/json"]) }
  4. Resources 4 I'll be releasing a sample project on GitHub

    at some point in the next week or two. 4 ObjC.io VIPER: http://bit.ly/1Ht1V6Y 4 ObjC.io MVVM: http://bit.ly/1UNLXJf 4 ObjC.io Lightweight View Controllers: http://bit.ly/ 1K1wAtw 4 WWDC Session 229