San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

43
The Restless Are Getting Native Lessons Learnt While Automating an iOS App Dante Briones Principal Consultant Cochiva Friday, March 23, 12

description

Are you wondering how to write automated tests for your shiny new iOS application? Is it even possible? Maybe you're sick of manually running the same test scenarios over and over and over… are you developing blisters on your fingertips?In his talk, Dante Briones--Principal Consultant for Cochiva--will give a broad overview of the automated testing tools currently available for iOS, and share some hard-won secrets of iOS app test automation using NativeDriver -- an implementation of the WebDriver API that can drive *native* applications running on iOS or Android. You'll see how to integrate NativeDriver into your iOS app, allowing you to write functional tests in Java. You'll learn how to execute those tests at the command line and how to integrate those tests into a continuous integration tool like Jenkins. You'll hear lots of tips about how to improve your chances for a successful adoption of a functional testing suite.

Transcript of San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Page 1: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

The Restless Are Getting Native

Lessons Learnt While Automating an iOS App

Dante BrionesPrincipal Consultant

Cochiva

Friday, March 23, 12

Page 2: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

What makes a good automation tool?

Friday, March 23, 12

Page 3: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

I want tests that:

• are robust

• are easy to maintain

• clearly express intent

• are written in a real programming language

• run in any environment

• run on simulator or real device

Friday, March 23, 12

Page 4: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

These are important, but...

Friday, March 23, 12

Page 5: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

What’s the point of automated tests?

• To catch regression bugs

• To do so faster and more reliably than a human

Friday, March 23, 12

Page 6: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Developer

CommitSource Repo

Production

Build & Deploy

UserUses

Friday, March 23, 12

Page 7: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Developer

CommitSource Repo

Production

Build & Deploy

UserUses

Test Environment

TesterFeedback

Tests

Build & Deploy

Friday, March 23, 12

Page 8: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Developer

CommitSource Repo

Production

Build & Deploy

UserUses

Test Environment

TesterFeedback

Tests

Build & Deploy

Continuous Integration

Environment

Build & Deploy

Feedback

Friday, March 23, 12

Page 9: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Developer

CommitSource Repo

Production

Build & Deploy

UserUses

Test Environment

TesterFeedback

Tests

Build & Deploy

Continuous Integration

Environment

Build & Deploy

Feedback

Feedback

Local Test Environment

Tests

Friday, March 23, 12

Page 10: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

What’s the biggest win of automated tests?

FASTER FEEDBACK

Friday, March 23, 12

Page 11: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Development Team Automation Team

Tests

Test Environment

Deploy Run

Feedback

Friday, March 23, 12

Page 12: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Friday, March 23, 12

Page 13: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Development / Automation Team

Tests

Test Environment

DeployRun

Feedback

Friday, March 23, 12

Page 14: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Something to consider

"If a test fails in Jenkins,

and no one is there who cares about it,

should it still break the build?"

Friday, March 23, 12

Page 15: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

</digression>

Friday, March 23, 12

Page 16: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

iOS Automation: Tools

• NativeDriver http://nativedriver.googlecode.com/

• KIF https://github.com/square/KIF

• Frank http://www.testingwithfrank.com/

• MonkeyTalk http://www.gorillalogic.com/

• LessPainful https://www.lesspainful.com/

• iCuke https://github.com/unboxed/icuke

• UISpec http://uispec.googlecode.com/

Friday, March 23, 12

Page 17: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

iOS Automation: Architecture

Device / Simulator

Application

HTTP Server

Test Code

Request / Response

Synthesized Events

StateQuery

Friday, March 23, 12

Page 18: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

iOS Automation: Architecture

Device / Simulator

Application

Test Code

Friday, March 23, 12

Page 19: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Why NativeDriver?

Familiar API

Friday, March 23, 12

Page 20: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Why NativeDriver?

Java

Friday, March 23, 12

Page 21: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Why NativeDriver?

Android

Friday, March 23, 12

Page 22: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Why NativeDriver?

“Hybrid” Apps

Friday, March 23, 12

Page 23: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

iOS Automation Toolchain

Device / Simulator

Application (Obj-C)

HTTP Server

Test Code (Java)

WebDriver Protocol

Synthesized Events

StateQuery

Friday, March 23, 12

Page 24: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

NativeDriver Test Support Code

Friday, March 23, 12

Page 25: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

NativeDriver Test Code

Friday, March 23, 12

Page 26: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Toolchain: The ugly bits

• How do I build from the command line?

• How do I launch the simulator from the command line?

• How do I shut down the simulator cleanly?

Friday, March 23, 12

Page 27: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Toolchain: The ugly bits

• How do I browse native widgets currently onscreen?

• How do I browse widgets in a UIWebView?

• How do I solve intermittent test failures?

• What do I do if NativeDriver doesn’t support an element I need to interact with?

Friday, March 23, 12

Page 28: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Challenges

Friday, March 23, 12

Page 29: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Cultural Differences

Football Football

Friday, March 23, 12

Page 30: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Web Test Automation

• Selenium, Watir, Capybara, HTMLUnit, etc.

• Test automation is commonplace

Friday, March 23, 12

Page 31: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

iOS Test Automation

Real Developers Don’t Write Tests

Friday, March 23, 12

Page 32: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Challenges:Language Choice

Friday, March 23, 12

Page 33: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Recommendations

Friday, March 23, 12

Page 34: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Recommendation:Show Value Early

Friday, March 23, 12

Page 35: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Recommendation: Surprise and Delight

Friday, March 23, 12

Page 36: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Friday, March 23, 12

Page 37: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Friday, March 23, 12

Page 38: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Recommendation: Smooth Rough Edges

Friday, March 23, 12

Page 39: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Recommendation: Know Your Limits

Friday, March 23, 12

Page 40: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

The Future of NativeDriver

Friday, March 23, 12

Page 41: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Friday, March 23, 12

Page 42: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

The Future of Mobile Testing...

...is in your hands!

Friday, March 23, 12

Page 43: San Jose Selenium Meetup 22 Mar 2012: The Restless Are Getting Native

Thank you!

Dante [email protected]

@dantebriones

Friday, March 23, 12