Pro Yearly is on sale from $80 to $50! »

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
PRO

April 16, 2015
Tweet

Transcript

  1. UI Testing With Espresso 2.0 Ellen Shapiro AndroidListener Chicago, April

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

    created by Google.
  3. Espresso: What is? — Open-source UI testing framework for Android

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

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

    hierarchy — Only considers the portions of the view immediately visible to the user
  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
  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
  8. DEMO

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

    UI every single time.
  10. UI Testing Best Practices — Don't navigate through your entire

    UI every single time. — Use class and instance Before/After methods
  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
  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.
  13. Other Tips for UI Testing — Make a mock flavor,

    and test on it
  14. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data
  15. Shameless Vokal Plug Alert!

  16. Other Tips for UI Testing — Make a mock flavor,

    and test on it — Feed your networking stack mock data (Mocktrofit)
  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.
  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!
  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
  20. NOTE: If You're Using JUnit4... You should Bookmark Jake Wharton's

    gist for accessing the activity: https://gist.github.com/ JakeWharton/ 1c2f2cadab2ddd97f9fb
  21. Question Time!

  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