Android TDD Using JUnit, Robolectric and Mockito
Android now supports unit testing. Android unit testing runs on devices or emulators that adds extra time during development. I'm a big fan of TDD and the way android testing is done does not help me much. However... Thanks to Robolectric, headless testing is now possible by leveraging gradle. I wrote this post as a result of trying out several different approaches that confused me. Hopefully this one will help you set it up better. How? First, current common Android development projects are tightly coupled. Most stuffs are done in the Activity or Fragment, blame the tutorials. This makes it hard for us to actually do unit testing since a unit test should be isolated. The tight coupling makes unit testing impossible. Then, come this approach called Model - View - Presenter (MVP). MVP aims at separating concerns. The three components involved handles different concerns: Model This component groups all data related concerns. This component handles data que