SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
Take  your  mobile  app    
    tests  to  the  next  level  :  
  Continuous  Integration	

                  Eing Ong
Staff Software Engineer in Quality, Intuit, Inc.
Session  outline	
•    Mobile tests CI challenges
•    Android & iOS basics
•    Automation tools
•    Demo
•    Q&A




                                  2
CI  challenges  for  mobile  tests	
•  Mobile platforms
   o  OS, resolutions, screen sizes, memory, camera, processor
   o  Phone, tablets

•  Mobile integration
   o  Setup, execution, teardown
   o  Test results

•  Test automation technologies



                                                                 3
Setup  -­‐‑  Android	
•  Command
  $ANDROID_HOME/tools/emulator -avd $avd&
  Useful options: -wipe-data -no-boot-anim -noaudio

•  Tip #1: Android emulator plugin
   Start emulator, create snapshot, install, uninstall
   Limitation : Random port for emulator and adb

•  Tip #2 : Snapshot images
   emulator -avd <name> -snapshot <name>
   Useful option : -no-snapshot-save
   Limitation : Snapshot image timestamp



                                                         4
Setup  -­‐‑  Android	
•  Tip #3 : Setting current date
   adb shell date -s `date +"%Y%m%d.%H%M%S”`


•  Tip #4 : Restart android debug bridge
   adb devices | grep emulator
   adb kill-server; adb start-server


•  Tip #5 : Unlock emulator
   adb shell input keyevent 82
   adb shell input keyevent 4



                                               5
Setup  -­‐‑  iOS	
•  Tip #1 : Commands
  o  open -a "iPhone Simulator.app”

  o  iphonesim launch <app name> [sdkversion]

  o  instruments
         –t <automation tracetemplate> <app name>
         -w <deviceID>
         -e UIASCRIPT <scriptFilePath>
         -e UIARESULTSPATH <resultsFolderPath>



                                                    6
Setup  -­‐‑  iOS	
•  Tip #2 – Remove authorization prompt
   o  Administrative rights
   o  Update /etc/authorization
      <key>system.privilege.taskport</key>
         <dict>
            <key>allow-root</key>
               <!-- previous value <false/> -->
               <true/>


•  Tip #3 – Clean cache, preferences, SQLite
   o  ~/Library/Application Support/iPhone Simulator/{SDK}/Applications/<uuid>
       Library: Preferences, Caches
       Documents: sqlite3 <app>.sqlitedb


                                                                                 7
Install	
•  Android
   o  adb install <apk file>
         Multiple installs : find builds -name ‘*.apk’ -exec adb install "{}" ;

   o  adb uninstall <package name>


•  iOS
   o  No separate command needed




                                                                                   8
Launch	
•  Android
  adb shell am start
      -n <activity>
      [-a android.intent.action.MAIN]
      [-c android.intent.category.LAUNCHER]
      [-c android.intent.category.DEFAULT]


•  iOS
   o  Similar to setup/startup



                                              9
Mobile  tests  in  CI	

•    Build
•    Start emulator
•    Uninstall & install
•    Launch
•    Execute tests
•    Publish results




                           10
Mobile  automation  technologies	
•  Two categories
      •  Instrumented technique
      •  Non-instrumented technique

•  What is instrumentation?
      •    Tests are compiled with the app
      •    Tests are installed & launched with the app
      •    Source code is required and may need to be modified
      •    Only one app can be executed at a time
      •    White box


                                                                 11
Advantages  of  both  techniques	
Non-­‐‑instrumentation	
                 Instrumentation	

•  Device  platform  agnostic	
          •    Elements  can  be  accessed	
•  Test  code  reuse	
                   •    Debugging  ease	
•  Test  language  &  test  harness      •    Test  verification  ease	
   autonomy	
                            •    Reduce  tools  dependencies	
•  Support  for	
                        •    Support  for	
    Multi-­‐‑applications  testing	
           Installing  application	
    Custom  UI  elements	
                     Launching  application	
    Database/server  API  assertions	
         Cleanup  (kill  application)	
    Use  of  external  libraries	
             Test  execution  on  device	
      (e.g.  image  manipulation)	
            Code  coverage	


                                                                                12
Which  technique  should  I  use  ?	
   Non-instrumentation               Instrumentation


                      External  
                     interaction	
          Hardware                   Text-­‐‑based  
         interaction	
                features	

                  Image  based  
                    features	




                                                       13
Mobile  automation  tools	
 Mobile  	
       Non-­‐‑                 Instrumentation	
  OS	
      instrumentation	
 Android	
 eggPlant,  Sikuli,  MOET,   Robotium,  Calabash,  
           MonkeyRunner	
              MonkeyTalk	

   iOS	
    eggPlant,  Sikuli,  MOET	
 UIAutomation,  KIF,  
                                       iCuke,  Frank,  UISpec,  
                                       Zucchini,  Bwoken,  
                                       Calabash,  MonkeyTalk	




                                                                   14
MonkeyRunner	

•  API for controlling an Android device/emulator
   outside of Android code - developer.android.com
•  Actions
   o  Multiple emulators & devices interaction
   o  Captures screenshots
   o  Send keystrokes, gestures
   o  Start/stop/reconnect emulator
   o  Configure logging


                                                     15
Using  MonkeyRunner  in  Java	
•  Install Android SDK, tools & platform tools
•  Import Android jars & dependencies
   o  android.jar, androidprefs.jar, ddmlib.jar, guavalib.jar,
      hamcrest.jar, junit.jar, jython.jar, monkeyrunner.jar, sdklib.jar
•  Important classes
   o    com.android.monkeyrunner.adb.AdbBackend
   o    com.android.monkeyrunner.adb.AdbMonkeyDevice
   o    com.android.monkeyrunner.MonkeyImage
   o    com.android.monkeyrunner.MonkeyManager



                                                                          16
Using  MonkeyRunner  in  Java	
public static AdbBackend adbConn = new AdbBackend();
public static AdbMonkeyDevice device;

device = (AdbMonkeyDevice) adbConn.waitForConnection(timeout, deviceId);

device.shell(" am start -n " + activity);
device.shell("kill " + pid);
device.press(KEYCODE_MENU, TouchPressType.DOWN_AND_UP);
device.touch(x, y, TouchPressType.DOWN_AND_UP);
device.type(“Hello World”);

For more details, see com.intuit.moet.Android.java (github.com/eing/moet)


                                                                            17
Sikuli	
•  Visual technology to automate and test GUI using
   images - sikuli.org
•  Platform and OS agnostic
       •  Controls on desktop
       •  Controls mobile simulators and devices (via VNC)

•  Actions
       •    Captures screenshots
       •    Detects screen changes
       •    Send keystrokes, gestures
       •    Finds image, image OCR


                                                             18
Using  Sikuli  in  Java	
•  Install Sikuli-IDE.app
   o  Import sikuli-script.jar
   o  Start using org.sikuli.script.*

•  Important classes
   o    org.sikuli.script.App
   o    org.sikuli.script.Region
   o    org.sikuli.script.Screen
   o    org.sikuli.script.ScreenImage



                                        19
Using  Sikuli  in  Java	
public static App app = new App(settings.iphoneExec);
public static Screen screen = new Screen();

screen.setRect(app.window());
region = new Region (screen.getRect());

region.click(new Location(x,y), 0); // Tap screen
region.click(“homebutton.png”, 0); // Tap on image
region.text();                          // Get screen text
region.type(null, inputString, 0);      // Type in focused field
screen.capture(region.getRect());       // Capture screenshot

For more details, pls see com.intuit.moet.iPhone.java (github.com/eing/moet)
                                                                               20
MOET	
                                   Test
github.com/eing/moet	
                   Login(“user1”,”passwd1”)

•  Think design                           iPhone implementation
  o  Creational pattern                         touch(100,100)
                                                enter(username)
•  Think reuse                                  touch(100,200)
  o  Device independent tests                   enter(password)
                                                touch(150, 300)
•  Think One
   o  IDE, test language, test harness     iPhone Sikuli library
                                               void enter()
                                               void touch(x,y)


                                                                    21
Test  architecture  using  MOET	
             Mobile  Application  Interface
                                         	


             Device  Independent  Tests
                                     	
                   Runtime binding
 Simulator libraries
    Android  application       iPhone  application  
      implementation 	
          implementation 	
   Android  MonkeyRunner  
                              iPhone  Sikuli  Library
                                                    	
            Library
                  	


                                                         22
Demo	
•  Run a mobile test in CI
  •  Android
      •  MonkeyRunner, MOET test
      •  Install app, launch app,
            run test, stop app
  •  iPhone
      •  Sikuli, MOET test
      •  Start simulator, launch app,
            run test, stop app




                                        23
Resources	
•    Android testing
         http://developer.android.com/tools/help/index.html
         http://www.java2s.com/Open-Source/Android/android-core/platform-
         sdk/com/android/monkeyrunner/MonkeyRunner.java.htm
         http://code.google.com/p/robotium/
•    iOS testing
         http://sikuli.org/docx/faq/030-java-dev.html
         https://github.com/jhaynie/iphonesim/
         http://sikuli.org/doc/java-x/index.html?org/sikuli/script/Region.html
•    MOET
         https://github.com/eing/moet/tree/master/java/src/com/intuit/moet
•    Jenkins
         http://jenkins-ci.org/


                                                                                 24
Q  &  A	




            25
Thank  you	
Thank you for your session survey& feedback !

    For more details on this presentation,
              please contact
      @eingong / eing.ong@intuit.com




                                                26
Jenkins  Premier	

1.  Start Jenkins
   o    java –jar jenkins.war (or drop war file in servlet container)
2.  Administer Jenkins
   o    http://<hostname>:8080 (add /jenkins for war deploy)
   o    Install plugins
        •  e.g. Perforce, Maven, JUnit, Android emulator

3.  Create a new job
   o    Setup source code management
   o    Build triggers
   o    Build steps
   o    Publish test report


                                                                        27

Contenu connexe

Tendances

Engineering and Industrial Mobile Application (APP) Development
Engineering and Industrial Mobile Application (APP) DevelopmentEngineering and Industrial Mobile Application (APP) Development
Engineering and Industrial Mobile Application (APP) DevelopmentLiving Online
 
Code and Conquer with Globe Labs, October 27, 2012
Code and Conquer with Globe Labs, October 27, 2012Code and Conquer with Globe Labs, October 27, 2012
Code and Conquer with Globe Labs, October 27, 2012jobandesther
 
A guide to Android automated testing
A guide to Android automated testingA guide to Android automated testing
A guide to Android automated testingjotaemepereira
 
Automate Mobile App Testing—Or Go Crazy
Automate Mobile App Testing—Or Go CrazyAutomate Mobile App Testing—Or Go Crazy
Automate Mobile App Testing—Or Go CrazyTechWell
 
Best Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBest Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBitbar
 
Utilisation des capteurs dans les applications windows 8
Utilisation des capteurs dans les applications windows 8Utilisation des capteurs dans les applications windows 8
Utilisation des capteurs dans les applications windows 8Intel Developer Zone Community
 
Rationalize Android Development with StAnD - Clement Escoffier, akquinet
Rationalize Android Development with StAnD - Clement Escoffier, akquinetRationalize Android Development with StAnD - Clement Escoffier, akquinet
Rationalize Android Development with StAnD - Clement Escoffier, akquinetParis Open Source Summit
 
Developing Series 40 Java Apps for Multiple UI Patterns
Developing Series 40 Java Apps for Multiple UI PatternsDeveloping Series 40 Java Apps for Multiple UI Patterns
Developing Series 40 Java Apps for Multiple UI PatternsMicrosoft Mobile Developer
 
Testing on Android
Testing on AndroidTesting on Android
Testing on AndroidAri Lacenski
 
Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29Hugo Josefson
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Codemotion
 
Automated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerAutomated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerKyungmin Lee
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your appEyal Lezmy
 
Android studio
Android studioAndroid studio
Android studioAndri Yabu
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with OreoOpersys inc.
 

Tendances (20)

Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
Engineering and Industrial Mobile Application (APP) Development
Engineering and Industrial Mobile Application (APP) DevelopmentEngineering and Industrial Mobile Application (APP) Development
Engineering and Industrial Mobile Application (APP) Development
 
Code and Conquer with Globe Labs, October 27, 2012
Code and Conquer with Globe Labs, October 27, 2012Code and Conquer with Globe Labs, October 27, 2012
Code and Conquer with Globe Labs, October 27, 2012
 
A guide to Android automated testing
A guide to Android automated testingA guide to Android automated testing
A guide to Android automated testing
 
Automate Mobile App Testing—Or Go Crazy
Automate Mobile App Testing—Or Go CrazyAutomate Mobile App Testing—Or Go Crazy
Automate Mobile App Testing—Or Go Crazy
 
Best Practices in Mobile Game Testing
Best Practices in Mobile Game TestingBest Practices in Mobile Game Testing
Best Practices in Mobile Game Testing
 
Utilisation des capteurs dans les applications windows 8
Utilisation des capteurs dans les applications windows 8Utilisation des capteurs dans les applications windows 8
Utilisation des capteurs dans les applications windows 8
 
Rationalize Android Development with StAnD - Clement Escoffier, akquinet
Rationalize Android Development with StAnD - Clement Escoffier, akquinetRationalize Android Development with StAnD - Clement Escoffier, akquinet
Rationalize Android Development with StAnD - Clement Escoffier, akquinet
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Developing Series 40 Java Apps for Multiple UI Patterns
Developing Series 40 Java Apps for Multiple UI PatternsDeveloping Series 40 Java Apps for Multiple UI Patterns
Developing Series 40 Java Apps for Multiple UI Patterns
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29Robotium at Android Only 2010-09-29
Robotium at Android Only 2010-09-29
 
Sikuli
SikuliSikuli
Sikuli
 
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
Debug, Analyze and Optimize Games with Intel Tools - Matteo Valoriani - Codem...
 
Automated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracerAutomated Historical Performance Analysis with kmemtracer
Automated Historical Performance Analysis with kmemtracer
 
Robotium Tutorial
Robotium TutorialRobotium Tutorial
Robotium Tutorial
 
Android, the life of your app
Android, the life of your appAndroid, the life of your app
Android, the life of your app
 
Android studio
Android studioAndroid studio
Android studio
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
 

Similaire à 2012 java one-con3648

Fight back android fragmentation
Fight back android fragmentationFight back android fragmentation
Fight back android fragmentationBitbar
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testingDipesh Bhatewara
 
Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)danielputerman
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testingbdipesh
 
Android village @nullcon 2012
Android village @nullcon 2012 Android village @nullcon 2012
Android village @nullcon 2012 hakersinfo
 
Appium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanAppium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanApplitools
 
Mobile Application Testing
Mobile Application TestingMobile Application Testing
Mobile Application TestingSun Technlogies
 
Mobile Application Testing
Mobile Application Testing Mobile Application Testing
Mobile Application Testing Shivaraj R
 
Learning's from mobile testing
Learning's from mobile testingLearning's from mobile testing
Learning's from mobile testingVikrant Chauhan
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Kevin Munc
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Bitbar
 
Selenium in the palm of your hand: Appium and automated mobile testing
Selenium in the palm of your hand: Appium and automated mobile testingSelenium in the palm of your hand: Appium and automated mobile testing
Selenium in the palm of your hand: Appium and automated mobile testingIsaac Murchie
 
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Intuit Inc.
 
Monkey talk
Monkey talkMonkey talk
Monkey talkISsoft
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with AppiumSrijan Technologies
 
Introduction To Mobile-Automation
Introduction To Mobile-AutomationIntroduction To Mobile-Automation
Introduction To Mobile-AutomationMindfire Solutions
 
Mobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and DockerMobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and DockerMoataz Nabil
 
Mobile testingartifacts
Mobile testingartifactsMobile testingartifacts
Mobile testingartifactsPragya Rastogi
 

Similaire à 2012 java one-con3648 (20)

Fight back android fragmentation
Fight back android fragmentationFight back android fragmentation
Fight back android fragmentation
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testing
 
Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)Appium overview (Selenium Israel #2, Feb. 2014)
Appium overview (Selenium Israel #2, Feb. 2014)
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testing
 
Android village @nullcon 2012
Android village @nullcon 2012 Android village @nullcon 2012
Android village @nullcon 2012
 
Appium Overview - by Daniel Puterman
Appium Overview - by Daniel PutermanAppium Overview - by Daniel Puterman
Appium Overview - by Daniel Puterman
 
Mobile Application Testing
Mobile Application TestingMobile Application Testing
Mobile Application Testing
 
Mobile Application Testing
Mobile Application Testing Mobile Application Testing
Mobile Application Testing
 
Learning's from mobile testing
Learning's from mobile testingLearning's from mobile testing
Learning's from mobile testing
 
Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013Ci for i-os-codemash-01.2013
Ci for i-os-codemash-01.2013
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Selenium in the palm of your hand: Appium and automated mobile testing
Selenium in the palm of your hand: Appium and automated mobile testingSelenium in the palm of your hand: Appium and automated mobile testing
Selenium in the palm of your hand: Appium and automated mobile testing
 
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Monkey talk
Monkey talkMonkey talk
Monkey talk
 
mohit anand
 mohit anand mohit anand
mohit anand
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
 
Introduction To Mobile-Automation
Introduction To Mobile-AutomationIntroduction To Mobile-Automation
Introduction To Mobile-Automation
 
Mobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and DockerMobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and Docker
 
Mobile testingartifacts
Mobile testingartifactsMobile testingartifacts
Mobile testingartifacts
 

2012 java one-con3648

  • 1. Take  your  mobile  app     tests  to  the  next  level  :    Continuous  Integration Eing Ong Staff Software Engineer in Quality, Intuit, Inc.
  • 2. Session  outline •  Mobile tests CI challenges •  Android & iOS basics •  Automation tools •  Demo •  Q&A 2
  • 3. CI  challenges  for  mobile  tests •  Mobile platforms o  OS, resolutions, screen sizes, memory, camera, processor o  Phone, tablets •  Mobile integration o  Setup, execution, teardown o  Test results •  Test automation technologies 3
  • 4. Setup  -­‐‑  Android •  Command $ANDROID_HOME/tools/emulator -avd $avd& Useful options: -wipe-data -no-boot-anim -noaudio •  Tip #1: Android emulator plugin Start emulator, create snapshot, install, uninstall Limitation : Random port for emulator and adb •  Tip #2 : Snapshot images emulator -avd <name> -snapshot <name> Useful option : -no-snapshot-save Limitation : Snapshot image timestamp 4
  • 5. Setup  -­‐‑  Android •  Tip #3 : Setting current date adb shell date -s `date +"%Y%m%d.%H%M%S”` •  Tip #4 : Restart android debug bridge adb devices | grep emulator adb kill-server; adb start-server •  Tip #5 : Unlock emulator adb shell input keyevent 82 adb shell input keyevent 4 5
  • 6. Setup  -­‐‑  iOS •  Tip #1 : Commands o  open -a "iPhone Simulator.app” o  iphonesim launch <app name> [sdkversion] o  instruments –t <automation tracetemplate> <app name> -w <deviceID> -e UIASCRIPT <scriptFilePath> -e UIARESULTSPATH <resultsFolderPath> 6
  • 7. Setup  -­‐‑  iOS •  Tip #2 – Remove authorization prompt o  Administrative rights o  Update /etc/authorization <key>system.privilege.taskport</key> <dict> <key>allow-root</key> <!-- previous value <false/> --> <true/> •  Tip #3 – Clean cache, preferences, SQLite o  ~/Library/Application Support/iPhone Simulator/{SDK}/Applications/<uuid> Library: Preferences, Caches Documents: sqlite3 <app>.sqlitedb 7
  • 8. Install •  Android o  adb install <apk file> Multiple installs : find builds -name ‘*.apk’ -exec adb install "{}" ; o  adb uninstall <package name> •  iOS o  No separate command needed 8
  • 9. Launch •  Android adb shell am start -n <activity> [-a android.intent.action.MAIN] [-c android.intent.category.LAUNCHER] [-c android.intent.category.DEFAULT] •  iOS o  Similar to setup/startup 9
  • 10. Mobile  tests  in  CI •  Build •  Start emulator •  Uninstall & install •  Launch •  Execute tests •  Publish results 10
  • 11. Mobile  automation  technologies •  Two categories •  Instrumented technique •  Non-instrumented technique •  What is instrumentation? •  Tests are compiled with the app •  Tests are installed & launched with the app •  Source code is required and may need to be modified •  Only one app can be executed at a time •  White box 11
  • 12. Advantages  of  both  techniques Non-­‐‑instrumentation Instrumentation •  Device  platform  agnostic •  Elements  can  be  accessed •  Test  code  reuse •  Debugging  ease •  Test  language  &  test  harness   •  Test  verification  ease autonomy •  Reduce  tools  dependencies •  Support  for •  Support  for Multi-­‐‑applications  testing Installing  application Custom  UI  elements Launching  application Database/server  API  assertions Cleanup  (kill  application) Use  of  external  libraries Test  execution  on  device  (e.g.  image  manipulation) Code  coverage 12
  • 13. Which  technique  should  I  use  ? Non-instrumentation Instrumentation External   interaction Hardware   Text-­‐‑based   interaction features Image  based   features 13
  • 14. Mobile  automation  tools Mobile   Non-­‐‑ Instrumentation OS instrumentation Android eggPlant,  Sikuli,  MOET,   Robotium,  Calabash,   MonkeyRunner MonkeyTalk iOS eggPlant,  Sikuli,  MOET UIAutomation,  KIF,   iCuke,  Frank,  UISpec,   Zucchini,  Bwoken,   Calabash,  MonkeyTalk 14
  • 15. MonkeyRunner •  API for controlling an Android device/emulator outside of Android code - developer.android.com •  Actions o  Multiple emulators & devices interaction o  Captures screenshots o  Send keystrokes, gestures o  Start/stop/reconnect emulator o  Configure logging 15
  • 16. Using  MonkeyRunner  in  Java •  Install Android SDK, tools & platform tools •  Import Android jars & dependencies o  android.jar, androidprefs.jar, ddmlib.jar, guavalib.jar, hamcrest.jar, junit.jar, jython.jar, monkeyrunner.jar, sdklib.jar •  Important classes o  com.android.monkeyrunner.adb.AdbBackend o  com.android.monkeyrunner.adb.AdbMonkeyDevice o  com.android.monkeyrunner.MonkeyImage o  com.android.monkeyrunner.MonkeyManager 16
  • 17. Using  MonkeyRunner  in  Java public static AdbBackend adbConn = new AdbBackend(); public static AdbMonkeyDevice device; device = (AdbMonkeyDevice) adbConn.waitForConnection(timeout, deviceId); device.shell(" am start -n " + activity); device.shell("kill " + pid); device.press(KEYCODE_MENU, TouchPressType.DOWN_AND_UP); device.touch(x, y, TouchPressType.DOWN_AND_UP); device.type(“Hello World”); For more details, see com.intuit.moet.Android.java (github.com/eing/moet) 17
  • 18. Sikuli •  Visual technology to automate and test GUI using images - sikuli.org •  Platform and OS agnostic •  Controls on desktop •  Controls mobile simulators and devices (via VNC) •  Actions •  Captures screenshots •  Detects screen changes •  Send keystrokes, gestures •  Finds image, image OCR 18
  • 19. Using  Sikuli  in  Java •  Install Sikuli-IDE.app o  Import sikuli-script.jar o  Start using org.sikuli.script.* •  Important classes o  org.sikuli.script.App o  org.sikuli.script.Region o  org.sikuli.script.Screen o  org.sikuli.script.ScreenImage 19
  • 20. Using  Sikuli  in  Java public static App app = new App(settings.iphoneExec); public static Screen screen = new Screen(); screen.setRect(app.window()); region = new Region (screen.getRect()); region.click(new Location(x,y), 0); // Tap screen region.click(“homebutton.png”, 0); // Tap on image region.text(); // Get screen text region.type(null, inputString, 0); // Type in focused field screen.capture(region.getRect()); // Capture screenshot For more details, pls see com.intuit.moet.iPhone.java (github.com/eing/moet) 20
  • 21. MOET Test github.com/eing/moet Login(“user1”,”passwd1”) •  Think design iPhone implementation o  Creational pattern touch(100,100) enter(username) •  Think reuse touch(100,200) o  Device independent tests enter(password) touch(150, 300) •  Think One o  IDE, test language, test harness iPhone Sikuli library void enter() void touch(x,y) 21
  • 22. Test  architecture  using  MOET Mobile  Application  Interface Device  Independent  Tests Runtime binding Simulator libraries Android  application   iPhone  application   implementation implementation Android  MonkeyRunner   iPhone  Sikuli  Library Library 22
  • 23. Demo •  Run a mobile test in CI •  Android •  MonkeyRunner, MOET test •  Install app, launch app, run test, stop app •  iPhone •  Sikuli, MOET test •  Start simulator, launch app, run test, stop app 23
  • 24. Resources •  Android testing http://developer.android.com/tools/help/index.html http://www.java2s.com/Open-Source/Android/android-core/platform- sdk/com/android/monkeyrunner/MonkeyRunner.java.htm http://code.google.com/p/robotium/ •  iOS testing http://sikuli.org/docx/faq/030-java-dev.html https://github.com/jhaynie/iphonesim/ http://sikuli.org/doc/java-x/index.html?org/sikuli/script/Region.html •  MOET https://github.com/eing/moet/tree/master/java/src/com/intuit/moet •  Jenkins http://jenkins-ci.org/ 24
  • 25. Q  &  A 25
  • 26. Thank  you Thank you for your session survey& feedback ! For more details on this presentation, please contact @eingong / eing.ong@intuit.com 26
  • 27. Jenkins  Premier 1.  Start Jenkins o  java –jar jenkins.war (or drop war file in servlet container) 2.  Administer Jenkins o  http://<hostname>:8080 (add /jenkins for war deploy) o  Install plugins •  e.g. Perforce, Maven, JUnit, Android emulator 3.  Create a new job o  Setup source code management o  Build triggers o  Build steps o  Publish test report 27