Slide 1

Slide 1 text

Test-Driven Development for iOS Chris Trevarthen Monday, May 6, 13

Slide 2

Slide 2 text

this guy Monday, May 6, 13

Slide 3

Slide 3 text

How It All Began (For Me) Monday, May 6, 13

Slide 4

Slide 4 text

BASIC Monday, May 6, 13

Slide 5

Slide 5 text

C++ Monday, May 6, 13

Slide 6

Slide 6 text

Java Monday, May 6, 13

Slide 7

Slide 7 text

TDD Monday, May 6, 13

Slide 8

Slide 8 text

Testing Triangle (c) Patrick Wilson Welsh Monday, May 6, 13

Slide 9

Slide 9 text

iOS Testing - Unit • OCUnit • GHUnit • Kiwi Monday, May 6, 13

Slide 10

Slide 10 text

Kiwi - How to get it • Cocoapods! Monday, May 6, 13

Slide 11

Slide 11 text

Kiwi - How to get it Monday, May 6, 13

Slide 12

Slide 12 text

Kiwi - Project Setup • LogicSpecs • ApplicationSpecs Monday, May 6, 13

Slide 13

Slide 13 text

Kiwi - Project Setup Monday, May 6, 13

Slide 14

Slide 14 text

Kiwi - Spec Format Monday, May 6, 13

Slide 15

Slide 15 text

Kiwi - Mocking Monday, May 6, 13

Slide 16

Slide 16 text

Kiwi - Assertions Monday, May 6, 13

Slide 17

Slide 17 text

Kiwi - Output Monday, May 6, 13

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Code Coverage! Monday, May 6, 13

Slide 20

Slide 20 text

iOS Code Coverage Tools • CoverStory Monday, May 6, 13

Slide 21

Slide 21 text

iOS Code Coverage Tools • XCodeCoverage (+ lcov) Monday, May 6, 13

Slide 22

Slide 22 text

Testing Triangle (c) Patrick Wilson Welsh Monday, May 6, 13

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Calabash - Setup Monday, May 6, 13

Slide 26

Slide 26 text

Calabash - The Tests • Features • “As a” - “I want” - “So that” • Scenarios • “Given” - “When” - “Then” Monday, May 6, 13

Slide 27

Slide 27 text

Calabash - The Tests Monday, May 6, 13

Slide 28

Slide 28 text

Calabash - Running • Launch the new scheme from Xcode • “cucumber” • How does it know what to click? Monday, May 6, 13

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Calabash • Command-line tool to query while simulator is running • Helps to turn on accessibility tool on phone/simulator Monday, May 6, 13

Slide 31

Slide 31 text

Next Steps • xctool - Facebook’s alternative build tool - and it’s good! • ocunit2junit Monday, May 6, 13

Slide 32

Slide 32 text

(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

Slide 33

Slide 33 text

QUESTIONS? • @malusman • [email protected] Monday, May 6, 13