Created
February 9, 2011 05:44
-
-
Save abombss/817959 to your computer and use it in GitHub Desktop.
Robolectric test runner with modifications for RoboGuice 1.2-SNAPSHOT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RobolectricGuicyTestRunner extends RobolectricTestRunner { | |
public RobolectricGuicyTestRunner(Class testClass) throws InitializationError { | |
super(testClass, new File("./application").exists() ? new File("./application") : new File("./")); | |
} | |
@Override | |
protected Application createApplication() { | |
Application app = super.createApplication(); | |
Injector injector = RoboGuice.getInjector(Stage.PRODUCTION, app,new RoboModule(app), new RobolectricModule()); | |
return app; | |
} | |
@Override | |
public void prepareTest(Object test) { | |
Injector injector = RoboGuice.getInjector(Robolectric.application); | |
injector.getInstance(ContextScope.class).enter(Robolectric.application); | |
injector.injectMembers(test); | |
} | |
static class RobolectricModule extends AbstractModule { | |
@Override | |
protected void configure() { | |
bind(Ln.BaseConfig.class).toInstance(new RobolectricLoggerConfig()); | |
} | |
} | |
static class RobolectricLoggerConfig extends Ln.BaseConfig { | |
public RobolectricLoggerConfig() { | |
super(); | |
this.packageName = "robo"; | |
this.minimumLogLevel = Log.VERBOSE; | |
this.scope = "ROBO"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment