Download - Groovy Mobile Automation
![Page 1: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/1.jpg)
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Groovy Mobile AutomationBy Bobby Warner
![Page 2: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/2.jpg)
Who Am I
Bobby Warner Founder & President
!!
@bobbywarner2
![Page 3: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/3.jpg)
What is the objective?
• Functional test-cases written in Groovy & Spock that validate business functionality !
• Test-case suite that runs on multiple devices and platforms using Gradle !
• Automated execution of functional test-case suite
3
![Page 4: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/4.jpg)
Appium Automation Library
4
![Page 5: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/5.jpg)
What is Appium?
• Appium is an open source test automation framework for use with native and hybrid mobile apps. !
• It drives iOS and Android apps using the WebDriver JSON wire protocol. !
• Links: • http://appium.io • http://github.com/appium/appium
5
![Page 6: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/6.jpg)
Appium Philosophy
1. You shouldn’t have to recompile your app or modify it in any way in order to automate it.
2. You shouldn’t be locked into a specific language or framework to write and run your tests.
3. A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
4. A mobile automation framework should be open source, in spirit and practice as well as in name!
6
![Page 7: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/7.jpg)
#1
• You shouldn’t have to recompile your app or modify it in any way in order to automate it. !• Use vendor provided automation frameworks like
UIAutomation on iOS and UiAutomator on Android
7
![Page 8: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/8.jpg)
#2
• You shouldn’t be locked into a specific language or framework to write and run your tests. !• Wrap the vendor-provided frameworks in a common API
known as the WebDriver API !
• WebDriver provides a client-server protocol called JSON wire-protocol
8
![Page 9: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/9.jpg)
#3
• A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs.
!• WebDriver has become the de facto standard for automating
web browsers !
• WebDriver is a W3C Working Draft. !
• Appium extends the protocol with extra API methods useful for mobile automation.
9
![Page 10: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/10.jpg)
#4
• A mobile automation framework should be open source, in spirit and practice as well as in name! !• Many commercial automation tools are overhyped and they
constantly under deliver !
• Avoid vendor lock-in and expensive contracts
10
![Page 11: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/11.jpg)
What are the alternatives?
11
![Page 12: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/12.jpg)
Architecture
12
![Page 13: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/13.jpg)
What does it look like?
13
![Page 14: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/14.jpg)
Appium Java Client
• Simple wrapper of Selenium 2.x !
• Uses GSON (Google’s JSON library) for communicating with Appium REST end-points !
• Conforms to Mobile JSON Wire Protocol !
• Provides all the usual Selenium features plus specific mobile actions • tap, swipe, pinch, zoom, shake, scrollTo, and many more!
14
![Page 15: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/15.jpg)
Why use Groovy, Spock and Gradle?
• Groovy is very easy to learn for test engineers !
• Some test engineers already familiar with using Selenium with Java for traditional web automation
!• Spock helps keep these tests organized because they can get
out of control quickly !
• Gradle builds the test-suite and makes automating them very easy with a continuous integration server
15
![Page 16: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/16.jpg)
Selenium 3 and Mobile?
• Still a work in progress, steadily moving forward, a big update will likely be required !
• Android and iPhone Selenium drivers deprecated in favor of other compatible libraries • Like Appium!
16
![Page 17: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/17.jpg)
Demos
17
![Page 18: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/18.jpg)
Demo Build File
18
![Page 19: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/19.jpg)
Demo #1
• HelloSpec Demo • Test iOS and Android with separate tests
19
![Page 20: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/20.jpg)
Demo #2
• HelloSpec Demo with Helpers • Test iOS and Android together with one test and helpers
20
![Page 21: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/21.jpg)
Demo #3
• HelloSpec with Data • Test iOS and Android
together using Spock’s @Unroll
21
![Page 22: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/22.jpg)
Demo #4
• LocaleSpec Demo • Data-Driven Spock testing to change the locale and language for device • DesiredCapabilities class currently only supports locale for iOS • Have to implement a workaround for Android for now
22
![Page 23: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/23.jpg)
Demo #5
• AccountSpec Demo • Data-Driven Spock test for data entry to create an account • Tests blank passwords • Tests password confirmation field
23
![Page 24: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/24.jpg)
Continuous Integration
24
![Page 25: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/25.jpg)
Building the Apps
• Jenkins for Android and Test Suite • Best practice that has been used for years
!• XcodeBots for iOS
• Relatively new (last year’s WWDC with Xcode 5), but quickly becoming the defacto standard for continuous integration for iOS
!• Run both on a MacMini or MacPro (OSX required)
• Best practice is to setup one server for mobile continuous integration for both platforms that takes care of the usual iOS and Android publishing tasks like provisioning profiles, signing IPAs/APKs, etc.
25
![Page 26: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/26.jpg)
Running the Tests
• Separate jobs for test suite platforms and locales to run in parallel • Platform = OS + Hardware !
• Number of Test Jobs Grows Very Quickly! • iOS + iPhone 5S + en_US • iOS + iPhone 5S + es_ES • iOS + iPhone 5S + fr_FR • iOS + iPad + en_US • iOS + iPad + es_ES • iOS + iPad + fr_FR • And now all the possible Android combinations!
26
![Page 27: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/27.jpg)
Running the Tests
• iOS Simulators and Android Emulators • Limited • Simulator vs Emulator • Genymotion for Android
• Test devices plugged into the Mac • Test devices provided (i.e. Sauce Labs)
• Multiple platforms + multiple versions = 1000s of tests! • Run your tests on different device configurations as opposed to managing
your own test devices • Run tests in parallel (they take a long time to execute!)
27
![Page 28: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/28.jpg)
Where to go from here?
28
![Page 29: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/29.jpg)
Define a Testing Contract with Stakeholders
• What are the test configurations? • Android 2.3 still unbelievably has 13%, but don’t waste your time writing
automated tests for it. Focus on Android 4.0+ • Only worry about N and N-1 for iOS (today this is iOS 8 and iOS 7) !
• What is the goal for automated tests? • % of function points • % of user stories • % of test cases currently being run by QA
29
![Page 30: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/30.jpg)
Establish a Mobile Testing Strategy
• What can you rely on? • APIs you trust • APIs you can’t trust
!• What takes the most time testing your app today?
• Manual input of any data • Language based testing
!• How to find the right balance of mobile testing?
• The time it takes to maintain the test compared to the value they provide
30
![Page 31: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/31.jpg)
Establish a Mobile Testing Strategy
• Decoupling Components • Using a mobile test-suite to test back-end systems will not scale • Focus on testing each component separately
!• Automation Investment Pays for Itself
• 50 generalized test cases in 3 locales across 7 platforms = 1,050 tests • QA Teams don’t always do regression testing and this is the most valuable
aspect of automation testing (new feature didn’t break existing functionality) • Automation allows us to run all regression tests daily!
31
![Page 32: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/32.jpg)
Call To Action
• Write one functional test-case written in Groovy & Spock that validates some business functionality of your company’s mobile app • iOS or Android, but preferably both!
!• Show it to your QA department
• Most likely they will be very resistant at first because it’s completely foreign • Once they see the time that can be saved though, they’ll be hooked
32
![Page 33: Groovy Mobile Automation](https://reader035.vdocuments.net/reader035/viewer/2022062710/5594583a1a28ab4c2f8b4718/html5/thumbnails/33.jpg)
Q & A
33
!Thank you for attending this talk!
!Thank you SpringOne2GX organizers and sponsors!