Wednesday, January 30, 2013

Robolectric 2.0 alpha 1

Heya Android testers! There've been whispers, intimations, and innuendo of a major rev to Robolectric for a while now. We're happy to announce the first alpha version of Robolectric 2. The main goal for 2.0 is to accomplish more realistic Android simulation with much less need for shadow code.

This release is alpha-quality, and targeted at early adopters. We expect that there'll be bugs. We expect APIs to change before final release. Please use this alpha only if you can deal with some churn.

Big thanks to Square for giving us time to work on this.

Changes so far:

  • Using real android fragment manager code from the support lib.
  • More realistic resource loading, including system resources.
  • Much better support for resource qualifiers (e.g. locale, resolution, etc.).
  • Support for library projects.
  • Groundwork to remove many shadows and use actual android sdk code.
  • Moved to org.robolectric package and maven groupId.

Changes coming soon:

  • Removing many more shadows (most non-JNI Android classes should work without much shadowing).
  • Switching from javassist to ASM for faster startup.
  • Easier TestRunner setup and configuration.
  • Performance and memory use improvements.

Use it!

Add this to your pom (note the changed groupId):
Add a @RunWith to your test class and you're ready to go!
public class MyActivityTest {


If you're upgrading from Robolectric 1.x, you'll need to replace any reference to "com.xtremelabs.robolectric" in your project with "org.robolectric".

If you have a custom TestRunner, you'll need to change its configuration somewhat. We're expecting the custom TestRunner API to change soon.


If you find bugs, make an issue on our github project and label it with robolectric-2.


  1. Really good news. We've spotted already some test failures after migrating, but it seems like most of the things work. Soon we will report any problems we find.

    Thanks a lot for this alpha! I hope Final Release is coming really soon :-)

    1. Hoping to make this a quick release cycle, yep! Look forward to your bug reports!


    Thanks a ton fellas, awesome work.

  3. I'm trying to use this version to run tests via maven/intelliJ, but it fails to find the AndroidManifest (as intellij runs from project root location).

    In previous versions we'd create a custom test runner and set the path, but I see this 2 arg constructor is now removed, how do I go about this now?


  4. Are the any examples out there of testing Fragments? Or is it still not fully supported?

  5. Expect a new alpha release shortly which should have better fragment support.

  6. Good news. Thank you.