How ANDROID TESTING changed how we think about Death

1,015 views

Published on

"Irreproducible bugs become highly reproducible right after delivery to the customer". This is something that happens "almost" everyday.
It is well known that testing offers significant advantages as a development practice and helps ensure higher quality code with fewer defects.
Unfortunately, testing Android apps can be challenging, so in this session we are gonna talk about available tools and practices that could help us accomplish our goals.

Published in: Technology, Education
2 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total views
1,015
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
8
Comments
2
Likes
5
Embeds 0
No embeds

No notes for slide

How ANDROID TESTING changed how we think about Death

  1. 1. How ANDROID TESTING changed how we think about death… @fernando_cejas Code samples: https://github.com/android10/Inside_Android_Testing https://github.com/android10/AndroidApplicationTestingSample
  2. 2. Who am I… •  •  •  •  •  Software Engineer GDG Barcelona Organizer Android lover Geek Gintonic fan… …y un pelotudo…
  3. 3. Agenda?
  4. 4. Why testing..WTF? •  Testing increases the level of confidence in your code. •  Testing makes it possible to write new code, and refactor existing code, without worrying that you’ve broken existing functionality.
  5. 5. What is this mock thing? Martin Fowler: "...test-doubles ... preprogrammed with expectation"
  6. 6. GIVE A WARM WELCOME TO… mockito Mockito is a mocking framework that tastes really good. Mockito doesn't give you hangover because the tests are very readable and they produce clean verification errors.
  7. 7. Mockito Build-operate-check pattern
  8. 8. Mock initizalition
  9. 9. Initizalition using mockito test runner
  10. 10. Let’s verify some behaviour
  11. 11. Argument matchers
  12. 12. Verifying number of invocations / at least x / never
  13. 13. Making sure interaction(s) never happened on mock
  14. 14. Spying on real objects
  15. 15. Sounds familiar???
  16. 16. TO THE RESCUE… Allows you to run your android code on JVM. Allows loading of Android Classes in pure Java Projects.
  17. 17. Shadow Objects!
  18. 18. View and Resource Loading…
  19. 19. Shadow Activity Shadow ImageView
  20. 20. Robolectric 2.0+ •  •  •  •  •  Uses real Android SDK code Styles and themes supported System resources are available Performance improved Bugs fixed
  21. 21. Perform click Sample
  22. 22. Started Activity test Should have fragment test
  23. 23. Device Configuration Sample
  24. 24. Network sample Robolectric acts as a proxy!!!
  25. 25. Creating your own shadows
  26. 26. Creating your own shadows
  27. 27. Creating your own shadows
  28. 28. FEST Android •  A library by square (FTW!) •  It gives a chainable (or “fluent”) syntax for checking assertions. •  Makes tests easier to write (and read!).
  29. 29. Sample: code to modify a bitmap
  30. 30. Assertions with FEST
  31. 31. Dependency what? Dependency injection is a software design pattern that allows the removal of hard-coded dependencies and makes it possible to change them, whether at run-time or compile-time
  32. 32. Dagger Directed Acyclic Graph
  33. 33. Dagger Graph sample
  34. 34. Dagger sample
  35. 35. Declare dependencies
  36. 36. Satisfy dependencies
  37. 37. Build the graph
  38. 38. Modules
  39. 39. Spoon •  •  •  Acceptance tests (black box) Automation of test execution across multiple devices Aggregation of the results
  40. 40. Spoon •  Aggregation of screenshots while your tests are running
  41. 41. More tools… •  •  •  •  •  Robojuice Robotium Android Testing Framework UI Automator Monkey Runner
  42. 42. Best practices and some advice… •  •  •  •  •  Simplify your architecture Have a robust testing strategy Use continuous integration tools Mock/stub functionality Create your own test runner WRITE TESTS!!!
  43. 43. Questions?
  44. 44. THANKS!!! @fernando_cejas https://github.com/android10 jobs@tuenti.com http://corporate.tuenti.com/es/dev/blog

×