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.

8 comments:

  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 :-)

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

      Delete
  2. YEEEEEESSSSSSSSS!!!!!!!

    Thanks a ton fellas, awesome work.

    ReplyDelete
  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?

    Thanks

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

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

    ReplyDelete
  6. Bài viết rất hay: Chúng tôi chuyên cung cấp các sản phẩm chất lượng sau:


    Lều xông hơi tại nhà



    Lều xông hơi hồng ngoại



    Cảm ơn các bạn!

    ReplyDelete