Amplify - TDD on Android with Robolectric

871 views

Published on

Quick introduction to TDD on Android using Robolectric.

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
871
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
59
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Amplify - TDD on Android with Robolectric

  1. 1. The Magic of Android Unit Testing Johny Urgiles
  2. 2. Johny Urgiles ● 3 years @ Amplify ● Android dev for half of that ● Code quality aficionado ● The Lab for Robotics Education
  3. 3. Amplify & Test Driven Development ● Write test first ● See it fail ● Write simplest possible solution ● Refactor ● Sleep peacefully at night
  4. 4. Finished Product
  5. 5. Slow & Careful
  6. 6. Slow & Careful
  7. 7. Slow & Careful Fast & Risky
  8. 8. Slow & Careful Fast & Risky
  9. 9. Android & TDD ● Android Instrumentation Unit Testing ○ Pretty slow by unit test standards ○ We still have to maintain a separate infrastructure for tablet <-> tablet interaction
  10. 10. Android on JUnit
  11. 11. Stubbin
  12. 12. It’s Raining Runtime Exceptions
  13. 13. Robolectric 2.0 JVM Robolectric JUnit Test
  14. 14. Robolectric ● Mimics Android functionality ● 2.0 includes Android code (4.2.1 rc1) ● Provides view into Android internals ● Extendable with ‘Shadows’
  15. 15. Robolectric @ Amplify ● 4500 unit tests across our Android Apps ● Most in a single repo: 3751 ○ Runs in 6.5 minutes (Macbook Pro) ○ Migration to Robolectric 2.0 took a part-time dev about 3 weeks ○ Worth it ● Devs run unit tests in IntelliJ
  16. 16. Code Time
  17. 17. More Unit Testing @ Amplify ● RoboGuice ○ Based on Google Guice ○ Dependency injection for Android ● Mockito ○ Standard Java Mock library ● Android FEST ○ Assertion library by Square

×