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.

Espresso testing

This hands-on will feature getting started with automating Android with Espresso. We'll learn what’s Espresso, benefits of using it , tool set required for android app automation, writing a test using espresso API. We will start with setting up espresso using gradle and write test for single and multiple activities.
By: Deepika Verma, Nikhil Jain & Rohit Singhal

  • Login to see the comments

Espresso testing

  1. 1. Espresso Espresso By: Deepika, Nikhil & Rohit
  2. 2. What is Espresso?
  3. 3. Automated UI Testing
  4. 4. • What’s Espresso • Similar Frameworks for Automation • Why Expresso? • Advantages of Espresso • Set-Up • Hands-on with API discussion • API cheat sheet Agenda...
  5. 5. • A testing framework for Android to make it easy to write reliable UI tests for a single application • Developed internally at Google and open sourced in 2013 • Espresso 2.0 released in December 2015 and part of the Android Support Repository. Espresso
  6. 6. ● Robotium ● Appium ● Calabash ● Selendroid Similar Frameworks for Automation
  7. 7. Why ? and Benefits Problems Faced during automation? Testing framework is complex! Tests are flaky! Tests are slow and lasts hours! Not easy to write tests!
  8. 8. Why ? and Benefits(contd.) - Easy - Fast and Reliable - Backward Compatibility(Froyo is there) - Automatic Synchronization - Supports testing activities outside apps - Test Coverage
  9. 9. HOW ?? Dude It’s easy !! Dude, I can’t see !!
  10. 10. Writing Espresso Tests Espresso tests are based on a formula:-
  11. 11. onView(ViewMatcher) .perform(ViewAction) .check(ViewAssertion); Revealing The Formula !! Find Something Do Something Check Something
  12. 12. onView(withId(R.id.add_expense)) //ViewMatcher .perform(click()) // ViewAction .check(matches(withText("Add Expense"))); //Assertion Example
  13. 13. • Android Studio with Android SDK • Gradle • Espresso • Repo : git clone https://github.com/ajitsing/ExpenseManager Setup- Tools
  14. 14. Setup- Espresso with Gradle
  15. 15. • Simple test First Test
  16. 16. • Workflow Test Second Test
  17. 17. Entry point to interactions with views is via :- • onView(Matcher<View>) • onData(Matcher<? extends Object>) ViewMatcher - allows you to locate a view in the current view hierarchy Matcher: • withId() • withText() • isDisplayed() • withParent() • etc ViewMatcher Matches on User Properties Matches on UI properties Matches on with Hierarchy
  18. 18. ViewActions - allows you to interact with views • perform(ViewAction… viewActions) ViewAction: • click() • doubleClick() • longClick() • scrollTo() • swipeLeft() • clearText() • typeText() • etc ViewActions Click/Press Action Gestures Text centric Actions
  19. 19. ViewAssertions – allows you to assert the state of a view. • checks(ViewAssertion viewAssert) ViewAssertion: • matches(Matcher) • doesNotExist() ViewAssertions
  20. 20. API Cheatsheet

×