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

Test-Driven Development for iOS

Test-Driven Development for iOS

MobiDevDay 2013 talk on how to use test tools like Kiwi and Calabash to test-drive iOS apps.

Chris Trevarthen

May 04, 2013
Tweet

More Decks by Chris Trevarthen

Other Decks in Programming

Transcript

  1. I Have Tests - So What? • How do we

    know we’ve done a good job of testing our code? • How do we know potential problem areas in our code? Monday, May 6, 13
  2. Calabash and Cucumber • Behavior Driven Development • Given -

    When - Then (can be written by anyone in the organization) • Also exists for Android and tests can be reused! Monday, May 6, 13
  3. Calabash - How To Get It • Cocoapods support isn’t

    ready yet :( • It is a Ruby gem, though! • gem install calabash-cucumber • calabash-ios setup (adds Xcode target) • calabash-ios gen (adds features dir) Monday, May 6, 13
  4. Calabash - The Tests • Features • “As a” -

    “I want” - “So that” • Scenarios • “Given” - “When” - “Then” Monday, May 6, 13
  5. Calabash - Running • Launch the new scheme from Xcode

    • “cucumber” • How does it know what to click? Monday, May 6, 13
  6. Calabash - Built-In Steps • Screenshots: “take picture” • Touching:

    “Then I touch the ‘login’ button” • Entering text: “Then I enter ‘text’ into input field number 1” • Waiting: “Then I wait for the ‘login’ button to appear” • Back button: “Then I go back” • Swipes: “Then I swipe left” • Pinch: “Then I pinch to zoom in on ‘myLabel’ ” • Scrolling: “Then I scroll down” • Rotation: “Then I rotate device left” Monday, May 6, 13
  7. Calabash • Command-line tool to query while simulator is running

    • Helps to turn on accessibility tool on phone/simulator Monday, May 6, 13
  8. Next Steps • xctool - Facebook’s alternative build tool -

    and it’s good! • ocunit2junit Monday, May 6, 13
  9. (Re)Sources • Setting up testing in iOS: http://bit.ly/W8DDYd • Setting

    up Calabash for iOS: http://bit.ly/RZdrxr • http://cocoapods.org/ • https://github.com/allending/Kiwi • https://github.com/calabash/calabash-ios • https://github.com/facebook/xctool • https://code.google.com/p/coverstory/ • https://github.com/jonreid/XcodeCoverage • http://jenkins-ci.org/ • http://calaba.sh/ • OCUnit vs. GHUnit: http://bit.ly/dFbTCn • Testing Triangle: http://patrickwilsonwelsh.com/?p=32 Monday, May 6, 13