Skip to content

Instantly share code, notes, and snippets.

@avh4
Created April 5, 2012 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avh4/2306799 to your computer and use it in GitHub Desktop.
Save avh4/2306799 to your computer and use it in GitHub Desktop.
Robolectric Test Runner that sets up custom shadows
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.RobolectricTestRunner;
public class MyTestRunner extends RobolectricTestRunner {
public MyTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
addClassOrPackageToInstrument("com.package.ClassToShadow");
}
@Override
protected void bindShadowClasses() {
super.bindShadowClasses();
Robolectric.bindShadowClass(ShadowClassToShadow.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment