40
Testing for Android When, Where, and How to Successfully Use Test Automation Trent Peterson | @tdpeterson | [email protected]

Testing for Android: When, Where, and How to Successfully Use Test Automation

Embed Size (px)

DESCRIPTION

A high-level overview of test automation on the Android platform, beginning with a brief intro to software testing, how mobile isn't all that different from problems faced in the past, a tour of the most popular free tools available, and some words of advice. The slides accompanied a talk presented at the San Francisco Android User Group on October 29, hosted at Twitter.

Citation preview

Page 1: Testing for Android: When, Where, and How to Successfully Use Test Automation

Testing for AndroidWhen, Where, and How to

Successfully Use Test Automation

Trent Peterson | @tdpeterson | [email protected]

Page 2: Testing for Android: When, Where, and How to Successfully Use Test Automation

Who?

Page 3: Testing for Android: When, Where, and How to Successfully Use Test Automation

AGENDAWhat is testing?

What’s the problem?Why should I care?

When: Choosing our battlesWhere: Best Practices

How: Tools & FrameworksQ&A

Page 4: Testing for Android: When, Where, and How to Successfully Use Test Automation

INTRO TO TESTING

Page 5: Testing for Android: When, Where, and How to Successfully Use Test Automation

Types of tests

• Functional• Non-functional• Integration• Unit• Regression• Smoke• Usability• Performance

• Stress• Acceptance• Load• Sanity• End-to-End• System• SecurityAnd on and on…

Page 6: Testing for Android: When, Where, and How to Successfully Use Test Automation

Testing distilled for this discussion

Functional TestingNon-functional Testing

Page 7: Testing for Android: When, Where, and How to Successfully Use Test Automation

THE PROBLEM

Page 8: Testing for Android: When, Where, and How to Successfully Use Test Automation

Building things is hard.

Page 9: Testing for Android: When, Where, and How to Successfully Use Test Automation

WHY SHOULD I CARE?

Page 10: Testing for Android: When, Where, and How to Successfully Use Test Automation

1,000,000+ apps in

2 crashes and 84% will uninstall- Compuware as reported in TechCrunch

YOURAPP

So what’s the big deal?

Page 11: Testing for Android: When, Where, and How to Successfully Use Test Automation

We’ve been here before.

Page 12: Testing for Android: When, Where, and How to Successfully Use Test Automation

CHOOSING OUR BATTLES

Page 13: Testing for Android: When, Where, and How to Successfully Use Test Automation

First, what’s our goal?

Save time! Save

money! Shrink QA!

AUTOMATE EVERYTHING

!

BE REALISTIC• Increase regularity of testing• Free up resources for other testing efforts• Enable previously impossible tests

Page 14: Testing for Android: When, Where, and How to Successfully Use Test Automation

Deciding what to automate

How often will I test this?

Is this something a human is good at?

How much effort will automation require?

Page 15: Testing for Android: When, Where, and How to Successfully Use Test Automation

Some examples

AUTOMATE• Granular

functionality (unit tests)

• Repetitive tasks (update paths, navigation, etc.)

• Performance

MANUAL• UX• Responsiveness and

“feel”• New functionality

Page 16: Testing for Android: When, Where, and How to Successfully Use Test Automation

Our options (Machine)

JVM• FAST• Unit tests

only*• Mocks

Emulators• Cheap• Catch layout

issues• Simulate

calls/SMS• SLOW• Illusion of 1:1

with real devices

Real Devices• Exactly what

end customers use

• Performance data

• Fast• Expensive:

Purchase, maintain, etc.

Page 17: Testing for Android: When, Where, and How to Successfully Use Test Automation

Our options (Human)

QA• Pros• Real

feedback• Know the

product• Expensive

Crowd• Real feedback• Might know

product• Expensive

(usually)• Slow

End Users• Don’t do this.

Page 18: Testing for Android: When, Where, and How to Successfully Use Test Automation

BEST PRACTICES

Page 19: Testing for Android: When, Where, and How to Successfully Use Test Automation

No barriers between Dev & QA

Page 20: Testing for Android: When, Where, and How to Successfully Use Test Automation

Automation is a software project

Page 21: Testing for Android: When, Where, and How to Successfully Use Test Automation

Automation is a tool, not a solution

Page 22: Testing for Android: When, Where, and How to Successfully Use Test Automation

Automate with precision

Page 23: Testing for Android: When, Where, and How to Successfully Use Test Automation

It’s all about data

Page 24: Testing for Android: When, Where, and How to Successfully Use Test Automation

Know your matrix

RISK̂

Page 25: Testing for Android: When, Where, and How to Successfully Use Test Automation

Abstraction is important

…but don’t obsess

Page 26: Testing for Android: When, Where, and How to Successfully Use Test Automation

TOOLS and FRAMEWORKS

Page 27: Testing for Android: When, Where, and How to Successfully Use Test Automation

Tool: Recorders

GOOD• Fast• Non-developers can

create tests

BAD• Fragile• Difficult to maintain• Non-developers can

create tests

BEST PRACTICE• Treat as a fancy spy

Page 28: Testing for Android: When, Where, and How to Successfully Use Test Automation

Tool: UI Exerciser Monkey

$ adb shell monkey –p my.sweet.app –v 1000

Page 29: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: Android Testing Framework

SUMMARY• JUnit/Java• Instrumentation provides hooks into

Android SDK to control Android-specific functionality

• Very basic functionality supported

• The foundation for most Android testing. Learn it, use it, love it.

Page 30: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: UI Automator

SUMMARY• JUnit/Java• Extends testing framework with UI

selectors and manipulators• Handle/control system dialogs, etc

• 4.1+ only

• Excellent choice if you have the luxury of supporting 4.1+.

Page 31: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: Robolectric

SUMMARY• JUnit• Runs in JVM• Mocks Android functionality with

“shadow” objects• Super fast

• Not everything is mocked (also, mocks)

• Great for staying sane while developing

Page 32: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: Robotium

SUMMARY• JUnit extension• Runs on emulators and real devices• Oriented towards black-box testing and

ensuring real-world outcomes

• Limited to the app under test

• Great choice for developers going beyond basic unit testing and testing UI.

Page 33: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: Cucumber-based

SUMMARY• Human-readable tests• Runs on emulators and real devices• Cross-platform

• Complex scenarios require development• Behavior-driven design. Be careful!

• Great choice for simple flows and teams with limited developer resources.

Page 34: Testing for Android: When, Where, and How to Successfully Use Test Automation

Framework: Appium

SUMMARY• Supports many language adapters• Runs on emulators and real devices• Cross-platform

• New, and not all WebDriver concepts map intuitively to native apps

• Great choice for teams happy with Selenium and expanding to native.

Page 35: Testing for Android: When, Where, and How to Successfully Use Test Automation

Frameworks: Commercial

GOOD• Support• Added features and

integrations• Longevity?

BAD• Proprietary• Often heavy and

difficult to maintain• $$$

ADVICE• Evaluate very carefully and acknowledge lock-in.

Page 36: Testing for Android: When, Where, and How to Successfully Use Test Automation

Tool: Spoon

YOURAPP

Instrumentation Tests

Spoon

Page 37: Testing for Android: When, Where, and How to Successfully Use Test Automation

When choosing, ask…

What are we testing?

What are our automation goals?Who will write the automated

tests?

Page 38: Testing for Android: When, Where, and How to Successfully Use Test Automation

SHAMELESS PLUG

Page 39: Testing for Android: When, Where, and How to Successfully Use Test Automation

API• Continuous

Integration• IDE• Command Line

Clients• Browser-based

web app

Results• Interactive,

real-time report

• JSON data via API

AppThwack• 100s of non-rooted

devices• Parallel execution• Built-in compatibility

tests• Support for all popular

automation frameworks

APP

Page 40: Testing for Android: When, Where, and How to Successfully Use Test Automation

Q & A

Trent Peterson | @tdpeterson | [email protected]