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.

Overview the Challenges and Limitations of Android App Automation with Espresso by Jagmit Singh


Published on

During this SauceCon 2019 presentation, Jagmit demonstrates how to set up Espresso, develop/execute tests and identify elements, and execute the Espresso tests in a Continuous Integration environment using Jenkins and Firebase.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Overview the Challenges and Limitations of Android App Automation with Espresso by Jagmit Singh

  1. 1. Overcome the Challenges and Limitations of Android App Automation with Espresso Myself Jagmit Singh is a Senior Automation Engineer at CBC Digital Labs, responsible for UI Automation of Listen Apps
  2. 2. What is CBC? Canadian Broadcasting Corporation branded as CBC/Radio Canada is National Public Broadcaster for TV and Radio
  3. 3. Agenda ● What’s Espresso? ● Challenges in Android UI Automation ● Why Use Expresso? ● Writing Espresso Tests ● Espresso & TestButler ● Espresso & UIAutomator ● Continuous UI Testing using Espresso and Jenkins
  4. 4. What’s Espresso? ● A testing framework for Android to write reliable UI tests ● Developed internally by Google ● Run on devices running Android 2.2 and higher ● Instrumentation-based API works with AndroidJUnitRunner
  5. 5. Challenges in Android UI Automation. ● Tests are Flaky! ● Tests are Slow! ● Scaling Automation Scope - Testing Outside the App ● Some Difficulty in locating UI elements!
  6. 6. Why Use Espresso? ● Fast and Reliable ● Support testing activities outside the App ● Espresso tests are developed within the App ● Native Platform Developed by Google -- Always ahead of the curve
  7. 7. Writing Espresso Tests
  8. 8. Setup Espresso with Gradle Add Dependencies to build.gradle android { defaultConfig { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } } dependencies { androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' androidTestImplementation 'com.linkedin.testbutler:test-butler-library:1.4.0' }
  9. 9. Android Test Rules ● Make Use of JUnit @Rule Annotations ● Retry Rule @Rule public final RetryRule retry = new RetryRule(); ● Activity Test Rule The Activity under the Rule will be launched again in each Test @Rule public ActivityTestRule activityRule = new ActivityTestRule<>(MyActivity.class);
  10. 10. Sample Espresso Test
  11. 11. Espresso & Test Butler
  12. 12. How TestButler Works? ❖ Two Part Project: App and Library ❖ Espresso Tests depends on Library ❖ Install TestButler App on Emulator prior to running Tests ❖ TestButler App have permissions to change Device Settings
  13. 13. Espresso & Test Butler ❖ Controlling the environment with Espresso Tests ❖ Disable crash & App Not Responding (ANR) dialogs ❖ Turn Wifi ON/OFF ❖ Change Locale ❖ Set Screen Orientation ❖ Disable Animations - Espresso Tests Run Reliably
  14. 14. Espresso & UI Automator
  15. 15. Espresso & UI Automator Espresso allow to test many things inside your application in simple way UiAutomator allows test to access many system stuff, e.g. notification, another applications, contacts, dialer, etc.
  16. 16. Continuous UI Testing and Deployment with Espresso and Jenkins Execution at Firebase Espresso Tests Selected builds pushed to Fabric for Testing