A new functionality is not complete without being tested first. We, as developers, have fallen many times into the trap of submitting code changes without writing a passing test first, only to find that the expected behavior was broken on future iterations.
We learned the hard way that writing tests boosts our productivity, increases code quality, and helps us release more often. For this reason, Android provided several tools to help us test our apps from the early stages.
In the following two sections, we will talk about my favorite setup, Robolectric for unit testing and Espresso for integration testing.
Until Robolectric, writing unit tests meant that we had to run them on a real device or an emulator. ...