Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Testable Android Architecture

Chuck Greb
September 29, 2016

Testable Android Architecture

So many testing tools exist for Android including JUnit, Mockito, Robolectric, and Espresso. But how can you design your application to leverage each one most effectively? This talk introduces a modified version of the Model View Presenter (MVP) architecture to organize your code to be more flexible, maintainable, and testable.

Chuck Greb

September 29, 2016
Tweet

More Decks by Chuck Greb

Other Decks in Technology

Transcript

  1. Art is anything you can do well. Anything you can

    do with Quality. “ ” - Robert M. Pirsig
  2. Fragment Activity EditText Button Web Service Storage AsyncTask Activity Lifecycle

    System Services Fragment Fragment Lifecycle User Input Input Validation
  3. Fragment Activity Web Service Storage AsyncTask Activity Lifecycle System Services

    Fragment Fragment Lifecycle User Input setRetainInstance(true) EditText Button Input Validation
  4. Fragment Activity Web Service Storage AsyncTask Activity Lifecycle System Services

    Fragment Fragment Lifecycle User Input setRetainInstance(true) Intent Parcelable Extras EditText Button Input Validation
  5. Web Service Storage Activity Fragment Fragment AsyncTask setRetainInstance(true) Activity Lifecycle

    Fragment Lifecycle System Services User Input Intent ActivityInstrumentati onTestCase2 Parcelable Extras EditText Button Input Validation
  6. - Phil Karlton There are two hard things in computer

    science: cache invalidation, naming things, [and errors off by one.] “ ”
  7. Web Service Storage Activity Activity Lifecycle System Services User Input

    Presenter View Model Controller Button EditText Thread Input Validation
  8. Web Service Storage Activity Activity Lifecycle System Services User Input

    Presenter View Model Controller Thread Button EditText Input Validation
  9. A test is not a unit test if: → It

    talks to the database → It communicates across the network → It touches the file system → It can't run at the same time as any of your other unit tests → You have to do special things to your environment (such as editing config files) to run it. Michael Feathers, 2005 A Set of Unit Test Rules