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.

Tests everywhere

107 views

Published on

In this talk we review some of the last tools released by Google to improve the testing of our Android applications.

Published in: Mobile
  • Be the first to comment

  • Be the first to like this

Tests everywhere

  1. 1. Testseverywhere From unit testing to UI testing for Android
  2. 2. ★ @laura_morillo ★ SoftwareDeveloper atCabify ★ Tech&LadiesandAgileGirlsorganizer
  3. 3. wheredoIstart? https://io2015codelabs.appspot.com/
  4. 4. Androidtests UNITTESTS (runontheJVM) instrumentationtests (Runondeviceoremulator)
  5. 5. CONFIGURINGUNITTESTS 1. 2. 3.
  6. 6. Classtotest
  7. 7. TESTWIZARD
  8. 8. TestCalculator.java
  9. 9. TestCalculator.java
  10. 10. FirstTestImplementation JUnittraditionalassertmethods JUnitbetterassertmethod(withhamcrest!)
  11. 11. ExecutingUnitTests or
  12. 12. Checkingtestresults(AndroidStudio)
  13. 13. Checkingtestresults(Console)
  14. 14. Implementingthecode (That was easy!)
  15. 15. Anddone!
  16. 16. Configuringinstrumentation tests(I)
  17. 17. Configuringinstrumentation tests(II)
  18. 18. Configuringinstrumentation tests(III)
  19. 19. UITotest
  20. 20. ActivityTest
  21. 21. Espressotest
  22. 22. Espressotest:Step1
  23. 23. Espressotest:Step2
  24. 24. Espressotest:Step3
  25. 25. Espressoispowerful We can interact with views (onView) We can interact with data adapters (onData) Go back (pressBack) Open menus (openActionBarOverflowOrOptionsMenu and openContextualActionModeOverflowMenu) And check if the element is checked (isChecked), can be clicked (isClickable), is being displayed in the screen (isDisplayed)... Image courtesy of jesadaphorn at FreeDigitalPhotos.net
  26. 26. UITestingisnice…buttooslow
  27. 27. Solet’sdomoreJVMunit/Small test
  28. 28. Andwemocktheandroiddependencies
  29. 29. Butmockingisnotalwaysnice Parcellable example
  30. 30. Servicesalsoneedandroidwithoutui
  31. 31. Servicesrule!
  32. 32. Butnotallservicesrule! IntentService
  33. 33. EspressoIntentstestRule: Stubbing
  34. 34. EspressoIntentstestRule: Verification
  35. 35. Summary We have Unit tests (JVM) and Instrumentation Tests (Android Device) Add Unit test as much as possible. Add mocks for your dependencies when needed. ActivityTestRule to test activities controlling their lifecycle. ServiceTestRule to test Services controlling their lifecycle (but not valid for IntentService) Espresso IntentsTestRule to handle activities and stub and verify intents
  36. 36. Thankyou! Laura Morillo-Velarde @laura_morillo laura.morillovelarde@gmail.com

×