Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UI Testing With Espresso 2.0 - AndroidListener ...

UI Testing With Espresso 2.0 - AndroidListener Chicago, April 2015

A fun look in to UI testing with Android. Links at the end!

Avatar for Ellen Shapiro

Ellen Shapiro

April 16, 2015
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. Espresso: What is? — Open-source UI testing framework for Android

    created by Google. — A great way to integration-test your application
  2. Espresso: How work? — Hamcrest Matchers dig through the view

    hierarchy — Only considers the portions of the view immediately visible to the user
  3. Espresso: How work? — Hamcrest Matchers dig through the view

    hierarchy — Only considers the portions of the view immediately visible to the user — Can enter text, tap things, scroll, swipe out of the box
  4. Espresso: How work? — Hamcrest Matchers dig through the view

    hierarchy — Only considers the portions of the view immediately visible to the user — Can enter text, tap things, scroll, swipe out of the box — Create your own actions
  5. UI Testing Best Practices — Don't navigate through your entire

    UI every single time. — Use class and instance Before/After methods
  6. UI Testing Best Practices — Don't navigate through your entire

    UI every single time. — Use class and instance Before/After methods — Create a test class for each piece of your UI
  7. UI Testing Best Practices — Don't navigate through your entire

    UI every single time. — Use class and instance Before/After methods — Create a test class for each piece of your UI — If there are things you can test without the UI, test them without the UI.
  8. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data
  9. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit)
  10. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit) — Compare R.string string resources to what's on screen.
  11. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit) — Compare R.string string resources to what's on screen. — Remember when you need to scroll!
  12. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit) — Compare R.string string resources to what's on screen. — Remember when you need to scroll! — Get to a piece of your UI that's buried without having to tap 800 buttons yourself
  13. NOTE: If You're Using JUnit4... You should Bookmark Jake Wharton's

    gist for accessing the activity: https://gist.github.com/ JakeWharton/ 1c2f2cadab2ddd97f9fb
  14. Links Galore! — Quickstart: https://code.google.com/p/android-test- kit/wiki/EspressoStartGuide — Mocktrofit: https://github.com/vokal/mocktrofit —

    ActivityRule: https://gist.github.com/JakeWharton/ 1c2f2cadab2ddd97f9fb — My Frankenstein Sample Project: https://github.com/ designatednerd/AndroidListenerExamples