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.
13. First, what’s our goal?
Save time!
BE REALISTIC
Save money!
• Increase regularity of testing
Shrink QA!
• Free up resources for other testing efforts
• Enable previously impossible tests
AUTOMATE
EVERYTHING
!
14. Deciding what to automate
How often will I test this?
Is this something a human is good at?
How much effort will automation require?
15. Some examples
AUTOMATE
MANUAL
• Granular functionality
(unit tests)
• Repetitive tasks
(update paths,
navigation, etc.)
• Performance
• UX
• Responsiveness and
“feel”
• New functionality
16. Our options (Machine)
JVM
Emulators
Real Devices
• FAST
• Unit tests
only*
• Mocks
• Cheap
• Catch layout
issues
• Simulate
calls/SMS
• SLOW
• Illusion of 1:1
with real
devices
• Exactly what end
customers use
• Performance data
• Fast
• Expensive:
Purchase,
maintain, etc.
17. Our options (Human)
QA
Crowd
End Users
• Pros
• Real
feedback
• Know the
product
• Expensive
• Real feedback
• Might know
product
• Expensive
(usually)
• Slow
• Don’t do this.
27. Tool: Recorders
GOOD
BAD
• Fast
• Non-developers can
create tests
• Fragile
• Difficult to maintain
• Non-developers can
create tests
BEST PRACTICE
• Treat as a fancy spy
29. 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.
30. 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+.
31. 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
32. 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.
33. 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.
34. 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.
35. Frameworks: Commercial
GOOD
BAD
• Support
• Added features and
integrations
• Longevity?
• Proprietary
• Often heavy and
difficult to maintain
• $$$
ADVICE
• Evaluate very carefully and acknowledge lock-in.
39. API
• Continuous
Integration
• IDE
• Command Line
Clients
• Browser-based
web app
AppThwack
•
•
•
•
100s of non-rooted devices
Parallel execution
Built-in compatibility tests
Support for all popular
automation frameworks
Results
• Interactive, realtime report
• JSON data via
API
Picture courtesy of http://www.flickr.com/photos/schrierc/ (Creative Commons Attribution 2.0 Generic)
Picture courtesy of http://www.flickr.com/photos/conbon/ (Creative Commons Attribution 2.0 Generic)
Programming image by http://www.flickr.com/photos/riebart/ (Creative Commons Attribution 2.0 Generic)
TechCrunch article: http://techcrunch.com/2013/03/12/users-have-low-tolerance-for-buggy-apps-only-16-will-try-a-failing-app-more-than-twice/Trash can by Yellow Icon Design (http://www.yellowicon.com/) under GPU General Public License
Picture courtesy of http://www.flickr.com/photos/mulad/ (Creative Commons Attribution 2.0 Generic)
Suit image by http://www.flickr.com/photos/charlesfettinger/ (Creative Commons Attribution 2.0 Generic)
Picture courtesy of http://www.flickr.com/photos/wwarby/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/easylocum/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/riebart/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/zomgitsbrian/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/andreweason/ (Creative Commons Attribution 2.0 Generic)
Data image by http://www.flickr.com/photos/tensafefrogs/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/riebart/ (Creative Commons Attribution 2.0 Generic)
Wall image by http://www.flickr.com/photos/carbonnyc/ (Creative Commons Attribution 2.0 Generic)
Security image by http://www.flickr.com/photos/zigazou76/ (Creative Commons Attribution 2.0 Generic)