Using Mockito with Android

One of the challenges of testing Android applications is that while regular unit tests run on the local machine, any test that involves the Android API is an instrumented test and requires either an actual device or an emulator to run. As discussed on the Android developer website,[18] if you can mock classes from the Android library, you can improve the performance of your tests considerably.

While normally you don’t want to mock classes you don’t own, the Mockito Android library was specifically designed to help you perform unit tests on Android applications without requiring emulators or external devices. Android testing is a topic beyond the scope of this book, but be aware that Mockito knows about it and is able ...

Get Mockito Made Clear now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.