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):
<dependency>
  <groupId>org.robolectric</groupId>
  <artifactId>robolectric</artifactId>
  <version>2.0-alpha-1</version>
</dependency>
Add a @RunWith to your test class and you're ready to go!
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
  ...
}

Upgrading:


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.


Help:


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