Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android UI Testing with uiautomator

3,770 views

Published on

This presentation is about Android UI Testing with uiautomator library.

Demo test available on github: https://github.com/Janamou/android-ui-test

Published in: Mobile

Android UI Testing with uiautomator

  1. 1. Android UI Testing with uiautomator Jana Moudrá | @Janamou | +JanaMoudrá
  2. 2. Me Co-Founder at Juicymo GDG ČVUT Prague/GDG Prague Web, Android, Design, Dart about.me/janamou
  3. 3. Motivation
  4. 4. UI Testing UI testing ensures that your application returns the correct UI output in response to a sequence of user actions on a device. http://developer.android.com/tools/testing/testing_ui.html
  5. 5. UI Testing No knowledge of implementation Testing and implementation separated
  6. 6. Manual? Time consuming Not repeatable Error prone
  7. 7. Manual? Time consuming Not repeatable Error prone We want to automate
  8. 8. Android?
  9. 9. Android? uiautomator
  10. 10. Tests in Java Android 4.1 Device
  11. 11. How to test in 3 steps
  12. 12. 1 Create the App
  13. 13. 2 Prepare the Test
  14. 14. Prepare the Test Application is accessible Application is on the device Use uiautomatorviewer Set development environment Create the test
  15. 15. Development environment Java project + JUnit + uiautomator.jar + android.jar
  16. 16. Use uiautomatorviewer
  17. 17. Create the Test extend the UiAutomatorTestCase class
  18. 18. Use available classes UiDevice UiSelector UiObject UiCollection UiScrollable
  19. 19. UiSelector UiObject threeButton = new UiObject( new UiSelector().text("3")); threeButton.click();
  20. 20. UiSelector UiObject urlForm = new UiObject( new UiSelector() .resourceId("com.android.browser:id/url")); urlForm.setText("http://www.gug.cz"); getUiDevice().pressEnter();
  21. 21. What can I do with UiObject? Use gestures Retrieve attributes Set text No manipulation
  22. 22. We can use Asserts assertEquals(threeButton.getText(), "3");
  23. 23. 3 Run the Test
  24. 24. Run the Test 1) Build with Ant 2) Push to device 3) Run the test
  25. 25. DEMO
  26. 26. Thank You! Questions??? about.me/janamou

×