iPhone Application Testing          Testing apps in the real world                 iPhone App Testing - Copyright 2010 Ele...
Who am I?               Dan Pilone (dan@element84.com, @danpilone)                     Author of Head First Software Devel...
Standard iPhone Testing                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Automated Testing                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Why automate your tests?                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Verify your code does what                       you think.                 iPhone App Testing - Copyright 2010 Element 84...
Keeps your code doing it...                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Gives you license to make                         changes                 iPhone App Testing - Copyright 2010 Element 84, ...
Basic Unit Testing               Support is built into Xcode               Called Logic Tests by Apple               Run a...
Setting up Logic Tests                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add a Unit Test Bundle                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add a Test Case                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
nts                         E ach class represe                         a test suite                                      ...
iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Demo*             * Xcode 3.2.4 requires a workaround source file                 iPhone App Testing - Copyright 2010 Eleme...
ST* Macro Sample                           STAssertTrue                                STAssertEqualObjects               ...
Notes...               Run at build time and not easily debuggable               Don’t run in the real context of the app ...
Gives you license to make                         changes                 iPhone App Testing - Copyright 2010 Element 84, ...
Test Driven          Development                                                  Requirements                            ...
Test Driven Development works on a very simple cycle:                                                            First you...
Demo                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Application Level Testing               Test at the Integration Test Level               Run on a physical device         ...
Duplicate your app target                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add an App Test Bundle                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add the tests to the target                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add the test bundle                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Add a Test Case                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
-    (void) setUp {      !    appDelegate    = [[UIApplication sharedApplication] delegate];      !    viewController = ap...
Notes...               Only run on the device               Can tempt you to expose things publicly that might be         ...
iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
Full Application Testing                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
UIAutomation Testing               JavaScript based testing using UIAutomation               framework               Lever...
Notes...               Use tune_up.js                     Provides a nice assertion and test wrapper around               ...
Sample test                   test("Basic List", function(target, app) {                   ! UIALogger.logMessage("Checkin...
Run UIAutomation in Instruments                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
More UIAutomation          information               Session 306 from WWDC 2010 Videos               https://developer.app...
Automate TDD and BDD   Scenario Outline: selecting location for descriptions      When I tap "Library"      And I tap "Add...
iCuke               iPhone App integration testing with Cucumber               Includes basic set of steps for interacting...
Automate TDD and BDD                 iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
CI with iPhone Apps               Definitely achievable!               Requires some setup due to code signing             ...
Questions?                                                                               Dan Pilone                       ...
Upcoming SlideShare
Loading in...5
×

iPhone Application Testing

5,684

Published on

iPhone Application Testing slidedeck presented at the Think Vitamin iPhone App Development Conference on 28th September 2010. Discusses why you need iOS testing, automated unit testing and automated UI testing. Ties in with O'Reilly Breakdown videos available here: http://search.oreilly.com/?i=1&q=pilone+video&t1=Video&u1=q&u2=t1&facet=ContentType&act=fc_contenttype_Video

Published in: Technology
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,684
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide

Transcript of "iPhone Application Testing"

  1. 1. iPhone Application Testing Testing apps in the real world iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  2. 2. Who am I? Dan Pilone (dan@element84.com, @danpilone) Author of Head First Software Development and Head First iPhone and iPad Development Developed software for NASA, Raytheon, UPS, Hughes, and the Naval Research Laboratory Founder of Element 84, LLC iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  3. 3. Standard iPhone Testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  4. 4. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  5. 5. Automated Testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  6. 6. Why automate your tests? iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  7. 7. Verify your code does what you think. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  8. 8. Keeps your code doing it... iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  9. 9. Gives you license to make changes iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  10. 10. Basic Unit Testing Support is built into Xcode Called Logic Tests by Apple Run as part of your build process Small scope for testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  11. 11. Setting up Logic Tests iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  12. 12. Add a Unit Test Bundle iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  13. 13. Add a Test Case iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  14. 14. nts E ach class represe a test suite @implementation LogicTests - (void) testFail { ! STFail(@”This’ll never work.”); a Each method represents start } specific test and should with “test”. ber of @end There are a numrify code. assertions to ve iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  15. 15. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  16. 16. Demo* * Xcode 3.2.4 requires a workaround source file iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  17. 17. ST* Macro Sample STAssertTrue STAssertEqualObjects STAssertFalse STAssertEquals STAssertThrows STAssertNotNil iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  18. 18. Notes... Run at build time and not easily debuggable Don’t run in the real context of the app Can’t run on a real device Fully automatable in a CI environment iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  19. 19. Gives you license to make changes iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  20. 20. Test Driven Development Requirements Design Code Test (what’s done) An iteration contains all the stages of a complete process. Somewhat of a misnomer Largely a design process Red, Green, Refactor... iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  21. 21. Test Driven Development works on a very simple cycle: First you write a test that checks whatever functionality you’re about to write. Obviously it fails, since you haven’t implemented the functionality yet. This is the red stage, since your test GUI probably shows the test in red (failing). Next, implement the functionality to get that test to pass. That’s it. No more. Nothing fancy. Write the simplest code you can to get your test to pass. This is the green stage. Finally, after your test passes, you can go back in and clean up some things that you may have noticed while implementing your code. This is the refactor stage. In the example for Starbuzz, you don’t have any other code to refactor, so you can go right on to the next test. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  22. 22. Demo iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  23. 23. Application Level Testing Test at the Integration Test Level Run on a physical device Build on what you know about unit testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  24. 24. Duplicate your app target iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  25. 25. Add an App Test Bundle iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  26. 26. Add the tests to the target iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  27. 27. Add the test bundle iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  28. 28. Add a Test Case iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  29. 29. - (void) setUp { ! appDelegate = [[UIApplication sharedApplication] delegate]; ! viewController = appDelegate.rootViewController; ! rootView = viewController.view; } - (void) testAppDelegate { STAssertNotNil(appDelegate, @"App delegate is nil!"); } iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  30. 30. Notes... Only run on the device Can tempt you to expose things publicly that might be best left private Let you perform full integration and load testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  31. 31. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  32. 32. Full Application Testing iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  33. 33. UIAutomation Testing JavaScript based testing using UIAutomation framework Leverages iPhone accessibility to let you automate your application in the simulator Runs inside Instruments to support profiling Full support for logging, screen captures, gestures, orientation and multitasking iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  34. 34. Notes... Use tune_up.js Provides a nice assertion and test wrapper around UIAutomation http://github.com/alexvollmer/tuneup_js Must run in Instruments making it difficult to use in a CI environment iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  35. 35. Sample test test("Basic List", function(target, app) { ! UIALogger.logMessage("Checking initial row count…"); ! ! mainWindow = app.mainWindow(); ! var topicTable = mainWindow.tableViews()[0]; ! var initialCount = topicTable.cells().length; ! assertEquals(21, initialCount); }); iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  36. 36. Run UIAutomation in Instruments iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  37. 37. iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  38. 38. More UIAutomation information Session 306 from WWDC 2010 Videos https://developer.apple.com/wwdc/iphone/library/ documentation/DeveloperTools/Reference/ UIAutomationRef/index.html iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  39. 39. Automate TDD and BDD Scenario Outline: selecting location for descriptions When I tap "Library" And I tap "Add" And I scroll down to "Add or Remove Descriptions" And I tap "Add or Remove Descriptions" And I tap "<description>" And I tap "more info" And I scroll picker column 1 of 1 columns up <body_row> rows Then I should see "<body_part>" Scenarios: all body parts in muscle stiffness | description | body_row | body_part | | Muscle stiffness | 0 | not specified | | Muscle stiffness | 1 | right arm | | Muscle stiffness | 2 | right leg | | Muscle stiffness | 3 | right side | | Muscle stiffness | 4 | left arm | | Muscle stiffness | 5 | left leg | | Muscle stiffness | 6 | left side | iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  40. 40. iCuke iPhone App integration testing with Cucumber Includes basic set of steps for interacting with your app in the simulator Let’s you execute and test “app requirements” Not quite 100% there... Available here: http://github.com/unboxed/icuke iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  41. 41. Automate TDD and BDD iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  42. 42. CI with iPhone Apps Definitely achievable! Requires some setup due to code signing Uses xcodebuild to build your project just like Xcode Take advantage of tools like scan-build (Clang) and gcovr to generate static analysis and Cobertura reports Use ocunit2junit.rb to generate test reports iPhone App Testing - Copyright 2010 Element 84, LLCThursday, June 2, 2011
  43. 43. Questions? Dan Pilone @danpilone iPhone App Testing - Copyright 2010 Element 84, LLC dan@element84.comThursday, June 2, 2011

×