Slide 1

Slide 1 text

TESTING In iOS

Slide 2

Slide 2 text

Sam Soffes @samsoffes

Slide 3

Slide 3 text

I’m a software engineer at Scribd in San Francisco

Slide 4

Slide 4 text

So, testing... *sigh*

Slide 5

Slide 5 text

No one likes writing tests

Slide 6

Slide 6 text

Testing is important

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Testing is important

Slide 9

Slide 9 text

There are a lot of options GFXHPPE Š

Slide 10

Slide 10 text

Unit Testing

Slide 11

Slide 11 text

GHUnit

Slide 12

Slide 12 text

OCUnit

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

- (void)testFirstObject { NSArray *array = [[NSArray alloc] initWithObjects:@"foo", @"bar", nil]; GHAssertEqualObjects([array firstObject], @"foo", nil); [array release]; }

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Download at sstoolk.it

Slide 19

Slide 19 text

Automated Testing

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

var target = UIATarget.localTarget(); var application = target.frontMostApp(); var window = application.mainWindow(); var view = window.elements()[0];

Slide 24

Slide 24 text

var buttons = window.buttons(); // Check for a button on screen if (buttons.length != 1) { UIALogger.logFail("FAIL: The button is missing."); } else { UIALogger.logPass("PASS: There is a button on the screen."); }

Slide 25

Slide 25 text

// Make sure it's the button we want var button = buttons.firstWithName("Tap Me"); if (!button || button.toString() == "[object UIAElementNil]") { UIALogger.logFail("FAIL: The button is missing."); } else { UIALogger.logPass("Pass: The button is there."); }

Slide 26

Slide 26 text

// Tap the button button.tap(); // Check for the alert var alert = application.alert(); if (!alert || alert.toString() == "[object UIAElementNil]") { UIALogger.logFail("FAIL: The alert was not shown after pressing the button."); } else { UIALogger.logPass("PASS: The alert was shown after pressing the button."); }

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Performance Testing

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Questions?

Slide 36

Slide 36 text

Thanks! Get my slides at samsoff.es/talks

Slide 37

Slide 37 text

No content