Slide 1

Slide 1 text

Testing @DanToml

Slide 2

Slide 2 text

What? Test noun: A procedure intended to establish the quality, performance, or reliability of something, especially before it is taken into widespread use.

Slide 3

Slide 3 text

Why?

Slide 4

Slide 4 text

Tools

Slide 5

Slide 5 text

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) }

Slide 6

Slide 6 text

FBSnapshotTestCase // https://github.com/facebook/ios-snapshot-test-case func test_taylor_swift_view_displays_correct_image() { let viewModel = TaylorSwiftImageViewModel.testViewModel() let sut = TaylorSwiftImageView(viewModel: viewModel) FBSnapshotVerifyView(sut) }

Slide 7

Slide 7 text

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"]) }

Slide 8

Slide 8 text

UI Testing

Slide 9

Slide 9 text

Code Coverage

Slide 10

Slide 10 text

Architecture

Slide 11

Slide 11 text

Modal View Controller

Slide 12

Slide 12 text

Massive View Controller

Slide 13

Slide 13 text

Breaking it out

Slide 14

Slide 14 text

MVVM Model-View-ViewModel

Slide 15

Slide 15 text

Dependency Injection & Composability

Slide 16

Slide 16 text

Clarity

Slide 17

Slide 17 text

Use what works for you

Slide 18

Slide 18 text

Lets talk about Testing

Slide 19

Slide 19 text

Singletons

Slide 20

Slide 20 text

View Models

Slide 21

Slide 21 text

Views

Slide 22

Slide 22 text

View Controllers

Slide 23

Slide 23 text

Non-View Controllers

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Questions? Find me on Twitter: @dantoml