Robolectric (http://pivotal.github.com/robolectric/) 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, like
null, 0, or
false, and if provided it forwards method calls to shadow objects giving 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 ...