UI Testing With Espresso 2.0 - AndroidListener Chicago, April 2015

UI Testing With Espresso 2.0 - AndroidListener Chicago, April 2015

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

C4861b1dfdf3bbb21faec4a1acdf183d?s=128

Ellen Shapiro

April 16, 2015
Tweet

Transcript

  1. 3.

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

    created by Google. — A great way to integration-test your application
  2. 5.

    Espresso: How work? — Hamcrest Matchers dig through the view

    hierarchy — Only considers the portions of the view immediately visible to the user
  3. 6.

    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. 7.

    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. 8.
  6. 10.

    UI Testing Best Practices — Don't navigate through your entire

    UI every single time. — Use class and instance Before/After methods
  7. 11.

    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
  8. 12.

    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.
  9. 14.

    Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data
  10. 16.

    Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit)
  11. 17.

    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.
  12. 18.

    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!
  13. 19.

    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
  14. 20.

    NOTE: If You're Using JUnit4... You should Bookmark Jake Wharton's

    gist for accessing the activity: https://gist.github.com/ JakeWharton/ 1c2f2cadab2ddd97f9fb
  15. 22.

    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