How ANDROID TESTING
changed how we think about
death…
@fernando_cejas
Code samples:
https://github.com/android10/Inside_An...
Who am I… •  Software Engineer
•  GDG Barcelona Organizer
android10.org
•  Android lover
•  Geek
•  Gintonic fan…
Agenda?
Why testing..WTF?
•  Testing increases the level of confidence in
your code.
•  Testing makes it possible to write new code...
•  Unit testing
•  Integration Testing
•  Functional and System Testing
1.  Stress Testing
2.  Performance Testing
3.  Usa...
Martin Fowler:
"...test-doubles ... preprogrammed with
expectation"
What is this mock thing?
Mockito is a mocking framework that tastes
really good.
Mockito doesn't give you
hangover because the tests
are very reada...
Mockito
Build-operate-check pattern
Mock initizalition
Initizalition using mockito test runner
Let’s verify some behaviour
Argument matchers
Verifying number of invocations / at
least x / never
Making sure interaction(s) never
happened on mock
Spying on real objects
Sounds familiar???
Allows you to run your android
code on JVM.
Allows loading of Android
Classes in pure Java
Projects.
TO THE RESCUE…
Shadow Objects!
View and Resource Loading…
Shadow Activity
Shadow ImageView
•  Uses real Android SDK code
•  Styles and themes supported
•  System resources are available
•  Performance improved
•  ...
Perform click Sample
Started Activity test
Should have fragment test
Device Configuration Sample
Network sample
Robolectric acts as a proxy!!!
Creating your own shadows
Creating your own shadows
Creating your own shadows
•  A library by square (FTW!)
•  It gives a chainable (or “fluent”)
syntax for checking assertions.
•  Makes tests easier ...
Sample: code to modify a bitmap
Assertions with FEST
Dependency injection is a software design
pattern that allows the removal of hard-coded
dependencies and makes it possible...
Dagger
Directed
Acyclic
Graph
Dagger Graph sample
Dagger sample
Declare dependencies
Satisfy dependencies
Build the graph
Modules
Spoon
•  Acceptance tests (black box)
•  Automation of test execution across multiple
devices
•  Aggregation of the results
Spoon
•  Aggregation of screenshots while your tests
are running
•  Robojuice
•  Robotium
•  Android Testing Framework
•  UI Automator
•  Monkey Runner
•  Espresso
•  Calabash
More tools…
WRITE TESTS!!!
•  Simplify your architecture
•  Have a robust testing strategy
•  Use continuous integration tools
•  Mock...
DO NOT LET YOUR CODE TO BE BROKEN…
DO NOT BREAK EXISTING FUNCTIONLITY…
Questions?
@fernando_cejas
https://github.com/android10
http://android10.org
THANKS!!!
How ANDROID TESTING changed how we think about Death - Second Edition
Upcoming SlideShare
Loading in...5
×

How ANDROID TESTING changed how we think about Death - Second Edition

1,623

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: Engineering, Software, Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,623
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
31
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

How ANDROID TESTING changed how we think about Death - Second Edition

  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 Second Edition android10.org
  2. 2. Who am I… •  Software Engineer •  GDG Barcelona Organizer android10.org •  Android lover •  Geek •  Gintonic fan…
  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. •  Unit testing •  Integration Testing •  Functional and System Testing 1.  Stress Testing 2.  Performance Testing 3.  Usability Testing •  Acceptance Testing •  Regression Testing 1.  Smoke Testing Types of tests…
  6. 6. Martin Fowler: "...test-doubles ... preprogrammed with expectation" What is this mock thing?
  7. 7. 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. GIVE A WARM WELCOME TO… mockito
  8. 8. Mockito Build-operate-check pattern
  9. 9. Mock initizalition
  10. 10. Initizalition using mockito test runner
  11. 11. Let’s verify some behaviour
  12. 12. Argument matchers
  13. 13. Verifying number of invocations / at least x / never
  14. 14. Making sure interaction(s) never happened on mock
  15. 15. Spying on real objects
  16. 16. Sounds familiar???
  17. 17. Allows you to run your android code on JVM. Allows loading of Android Classes in pure Java Projects. TO THE RESCUE…
  18. 18. Shadow Objects!
  19. 19. View and Resource Loading…
  20. 20. Shadow Activity Shadow ImageView
  21. 21. •  Uses real Android SDK code •  Styles and themes supported •  System resources are available •  Performance improved •  Bugs fixed Robolectric 2.0+
  22. 22. Perform click Sample
  23. 23. Started Activity test Should have fragment test
  24. 24. Device Configuration Sample
  25. 25. Network sample Robolectric acts as a proxy!!!
  26. 26. Creating your own shadows
  27. 27. Creating your own shadows
  28. 28. Creating your own shadows
  29. 29. •  A library by square (FTW!) •  It gives a chainable (or “fluent”) syntax for checking assertions. •  Makes tests easier to write (and read!). FEST Android
  30. 30. Sample: code to modify a bitmap
  31. 31. Assertions with FEST
  32. 32. 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 Dependency what?
  33. 33. Dagger Directed Acyclic Graph
  34. 34. Dagger Graph sample
  35. 35. Dagger sample
  36. 36. Declare dependencies
  37. 37. Satisfy dependencies
  38. 38. Build the graph
  39. 39. Modules
  40. 40. Spoon •  Acceptance tests (black box) •  Automation of test execution across multiple devices •  Aggregation of the results
  41. 41. Spoon •  Aggregation of screenshots while your tests are running
  42. 42. •  Robojuice •  Robotium •  Android Testing Framework •  UI Automator •  Monkey Runner •  Espresso •  Calabash More tools…
  43. 43. WRITE TESTS!!! •  Simplify your architecture •  Have a robust testing strategy •  Use continuous integration tools •  Mock/stub functionality •  Create your own test runner Best practices and some advice…
  44. 44. DO NOT LET YOUR CODE TO BE BROKEN… DO NOT BREAK EXISTING FUNCTIONLITY…
  45. 45. Questions?
  46. 46. @fernando_cejas https://github.com/android10 http://android10.org THANKS!!!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×