Android: Unit testing Android applications with Robolectric and Mockito
问题 I have a Java library that uses a few things from the Android APIs. I'd like to use Mockito to write unit tests for this library. Is there a way I can go about this? Mockito doesn't play nice on the Dalvik VM, see this post: Using Mockito with Android virtual machine UPDATE: Since this post I've discovered Robolectric, and I've had the opportunity to work out of Pivotal Labs and make some small contributions to this library. I would recommend using this over the Android testing framework