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.