My verdict for unit testing on Android: it's 2015, and it's still somewhat broken.
Perhaps not as broken as it used to be, but still broken in some really fundamental ways.
We've been using Robolectric 1 for a very long time in the SoundCloud app and built up a substantial test suite (cloc counts about 73K lines of test code), but building something that mission critical on legacy software is of course a ticking time bomb.
After all the recent fuss about improvements in Android unit testing, I spent quite some time evaluating the different approaches to select the one that would offer us the greatest benefit with the least amount of friction (side note: it's 2015--why does unit testing require time to make it work? It should be as straight forward as drinking a cup of coffee.) I have to say I left disappointed; some things are broken by design, others are just broken. Brief summary:Variation 1: Running unit tests on a connected device
The obvious benefit here is one of confidence: you are instrumenting your code against an actual system image, with the same VM that will actually run your code in production. It's the real deal. In the past, this approach wasn't exactly a great solution for numerous reasons (poor emulator performance, impossible to use mocking libraries, no JUnit 4 support to name the biggest ones.)
This has gotten better: we have a JUnit 4 runner now , we have DexMaker (a bytecode backend for Dalvik) , and we have Genymotion, but one of the major problems still exists: the platform JAR is full of final classes and methods, so you either have to write your tests to take that into account, or move your code as far away from the platform as possible; which is likely a good idea anyway , but induces the cost of introducing abstractions that might purely exist for testability.Variation 2a: Running unit tests on the JVM (not using Robolectric)
With the arrival of "experimental unit testing support" (now not experimental anymore), we can now run tests from src/test/java using ordinary test runners. Since it's an ordinary Java unit test, you can use ordinary test setups and libraries, too. Rejoice! However, this approach still has several drawbacks.
Although a Gradle task has been introduced that strips the platform JAR of all finals and method bodies, as soon as your test subject is somehow entangled with the platform, like when using Intents or Bundles, your test will likely fail, since all these classes are stubbed out. Since Intent or Bundle are foundational platform types, they typically don't appear as collaborators in constructors, so you either have to come up with awkward indirections ("intent providers") or, again, move your code as far away from the platform as possible (again, see ) You will also likely end up wiring a lot of mocks in your tests, making your tests hard to read and understand (after all, that's one reason why Robolectric was initially created)
A final annoyance: why on Earth am I not able to see both unit tests and acceptance tests at the same time? Due to some idiosyncratic behavior in either AS or Gradle's Android plugin, only one Gradle source set containing tests can be active at once, as chosen by the "test artifact" setting in your build flavors. So unit tests are piggy backed on a system that it wasn't really built for, and it means that any refactorings you apply to one source set will not apply to the other source set, which is just asking for trouble. I hope this is only temporary and will get addressed with future versions of the AS (I assume it's a shortcoming of AS.)Variation 2b: Running unit tests on the JVM (using Robolectric)
After we tried so hard to move away from Robolectric 1, we closed the circle by opting for... Robolectric 3. At SoundCloud we decided it was the most preferable solution of the three. It comes with all the benefits of running a normal JUnit test, but doesn't penalize you for writing tests for classes that use things like Bundles directly. Unfortunately (--or fortunately?), the higher you go up in the layers, the more difficult it is (still) to unit test something, which is probably a signal that even with a powerful tool like Robolectric, you should test code that is close to the UI sparingly (if at all), and focus on testing presentation /logic/, business rules, and anything beneath. For instance, Robolectric hasn't quite figured out timing yet, so things like animations steered by a presenter might fail.  Overall it's a huge step forward from the initial release though, and comes nicely modularized. By combining test rules and base classes for your tests, you can also keep much of the setup boiler plate out of your actual test cases, so that you don't couple yourself too much to any RL specifics.