Introducing Robolectric

Robolectric (http://robolectric.org) is a unit test framework that intercepts the loading of Android classes and rewrites the method bodies. Robolectric re-defines Android methods so they return default values, such as null, 0, or false. If available, it forwards method calls to shadow objects, mimicking Android behavior.

A large number of shadow objects are provided, but this is far from complete coverage, however, it is improving constantly. This should also lead you to treat it as an evolving open source project, for which you should be ready to contribute to make it better, but also to depend on it with caution because you may discover that what you need for your tests has not been implemented yet. This is not in any ...

Get Learning Android Application Testing 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.