Wednesday, May 29, 2013

Robolectric 2.1

Robolectric 2.1 is released!

Features

  • Layout inflation is now handled by real Android OS code.
  • Improved support for “style” attribute and theme queries in layout attributes.
  • Implemented AssetManager.openXmlResourceParser().
  • Support for using disk-based SQLite databases.

Bug Fixes

  • ActionBarSherlock should work, pretty much.
  • Fixed bugs in Handler.sendMessageAtTime(), and various timing issues.
  • Numerous other fixes and improvements from the Robolectric community! Thank you contributors!

Known Issues

  • Animations aren’t well-supported.

From the creator of Robolectric...

If Burning Man, or LGBT stuff, or a little playground humor turn you off, you can safely skip this post. Depending on your work environment, this may be mildly NSFW.

Shameless plug alert! I have another sheep-related project. Total coincidence. This one is an art piece bound for Burning Man: a giant mobile sheep-bus with a big soundsystem, a social message, some crazy awesome light effects, an unusual mode of entry, and a bunch of other nifty stuff. Oh, and he just happens to be a gay sheep. Not that it makes a difference, right?

Our Kickstarter campaign is finishing in a couple days, and we'd love to make it to $15K. If Robolectric has made your life a little better, consider kicking in some bucks to help us make Robolectric's real-world cousin amazingly awesome!

Don't worry, I don't fancy myself a DJ: we're corralling some really top-notch DJs and live performers, both acclaimed and underground, from around the world to entertain and make magic. This project is bringing together an incredible team of artists, engineers, builders, planners, and performers to create a rolling party. He'll debut at Burning Man 2013, but he'll be making appearances at events off-playa as well.

BAAAHS Kickstarter (I'm the guy at the start of the video)
BAAAHS Facebook page

Thursday, May 23, 2013

Configuring Robolectric 2.0

In Robolectric 1.x, it was necessary to extend RobolectricTestRunner if you wanted to configure things differently.

From 2.0 on, most configuration can be accomplished using either the @Config annotation or by adding a special file on your classpath.

You can add the @Config annotation to individual test methods, or entire test classes.

If you'd like to apply a configuration to your entire project, create a file called "org.robolectric.Config.properties", and place it on your classpath. If you're using maven, you could put it in src/test/resources.

Example:

@Config(qualifiers="fr-land")
public void shouldDisplayThingsInFrench() {
  ...
}

Configurable values currently include which manifest to use, the SDK level and qualifiers to report, and the list of additional shadows to enable. See the @Config annotation documentation for details.

Also, remember that Robolectric will now look for a test version of your Application class, where you can do additional configuration which used to require subclassing RobolectricTestRunner.

Wednesday, May 15, 2013

Robolectric 2.0 final!


Robolectric 2.0 is, at long last, finished! Thanks for all the bug reports over the last week.

We'll have some blog posts in the coming week talking about new features.


Use it!

If you've been using Robolectric 1.x, see the blog post on migrating to Robolectric 2.0.

If you're new to Robolectric, just add this to your pom:
<dependency>
  <groupId>org.robolectric</groupId>
  <artifactId>robolectric</artifactId>
  <version>2.0</version>
</dependency>
Add a @RunWith to your test class and you're ready to go!
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
  ...
}

Help:

If you find bugs, make an issue on our github project.

Monday, May 13, 2013

Robolectric 2.0 RC2



Robolectric 2.0 is very nearly finalized! Thanks for all the bug reports over the last week.


Unless we find any showstopper bugs, I'll redeploy this as 2.0 final shortly.

Changes since alpha 3:

  • Bug fixes.
  • Performance improvements.

    Use it!

    If you've been using Robolectric 1.x, see the blog post on migrating to Robolectric 2.0.

    If you're new to Robolectric, just add this to your pom:
    <dependency>
      <groupId>org.robolectric</groupId>
      <artifactId>robolectric</artifactId>
      <version>2.0-rc2</version>
    </dependency>
    Add a @RunWith to your test class and you're ready to go!
    @RunWith(RobolectricTestRunner.class)
    public class MyActivityTest {
      ...
    }

    Help:

    If you find bugs, make an issue on our github project.

    Thursday, May 9, 2013

    Announcing the Robolectric 2.0 release (candidate)!

    We're very, very pleased to announce that Robolectric 2.0 is now feature complete and nearly ready to be minted (note the subtle lamb pun there)!

    Thank you to Square for giving us Day 4 of the Seven Days of Open Source campaign of free software awesomeness: Announcing Robolectric 2.0 RC.

    Robolectric has a new home!


    To give us more flexible management of access for community contributors, Robolectric is moving to its own GitHub org.

    From now on you'll find the main Robolectric GitHub project here: http://github.com/robolectric/robolectric

    You can update your git repos with this command:
    $ git remote set-url origin git://github.com/robolectric/robolectric.git

    Robolectric has a new home, but the folks behind it remain the same: big thanks to Pivotal Labs, Square, and other backers for time and support!

    Wednesday, May 8, 2013

    Robolectric 2.0 alpha 3


    I'm happy to announce the third alpha version of Robolectric 2!

    We're now feature-complete on Robolectric 2.0! As before, this release is alpha-quality, and targeted at early adopters. We expect that there'll be bugs. APIs may change somewhat before final release. Please use this alpha only if you can deal with some churn.

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


    Changes since alpha 2:

    • Massive realism upgrade: we removed many, many shadows, particularly for views and widgets, so they'll behave much more realistically.
    • Dramatically improved resource loading, with support for themes and styles.
    • Easier TestRunner setup and configuration.
    • The new @Config annotation to specify config for a test class or test method:
      • The SDK level to report: @Config(reportSdk=Build.VERSION_CODES.FROYO)
      • Qualifiers for resource loading: @Config(qualifiers="fr-port-hdpi")
      • Custom shadow classes to enable.
    • For classes and methods that aren't explicitly shadowed, Robolectric now calls through to the real SDK code.
    • Views now complain if you try to pass in a null Context. Don't do it!
    • SDK method execution is now much much faster, especially in cases where we use the actual SDK code rather than a shadow (which will increasingly be the normal case).
    • Performance and memory use improvements.

      Changes coming soon:

      • Ability to switch Android SDK level on a per-test basis. The @Config annotation will allow you to specify which version of the SDK to emulate: @Config(emulateSdk=Build.VERSION_CODES.FROYO)
      • Performance and memory use improvements.

        Use it!

        If you've been using Robolectric 1.x, see my blog post on migrating to Robolectric 2.0.

        If you're new to Robolectric, just add this to your pom:
        <dependency>
          <groupId>org.robolectric</groupId>
          <artifactId>robolectric</artifactId>
          <version>2.0-alpha-3</version>
        </dependency>
        Add a @RunWith to your test class and you're ready to go!
        @RunWith(RobolectricTestRunner.class)
        public class MyActivityTest {
          ...
        }

        Help:

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