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

Testing in iOS

Testing in iOS

In this talk, I discussed how to test your iOS application in three different ways: unit testing, automated UI testing, and performance testing. Testing is pretty important. You should do it.

I show some basic uses of GHUnit and several things in Instruments.

Avatar for Sam Soffes

Sam Soffes

April 15, 2011
Tweet

More Decks by Sam Soffes

Other Decks in Programming

Transcript

  1. - (void)testFirstObject { NSArray *array = [[NSArray alloc] initWithObjects:@"foo", @"bar",

    nil]; GHAssertEqualObjects([array firstObject], @"foo", nil); [array release]; }
  2. var target = UIATarget.localTarget(); var application = target.frontMostApp(); var window

    = application.mainWindow(); var view = window.elements()[0];
  3. 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."); }
  4. // 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."); }
  5. // 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."); }