2

I am trying to use robotium to test my Activities. I used guice and roboguice for Dependency injection all over my code.

Is there anything I have to do to allow Injection while running my automation tests? or is robotium going to do that for me?

Please provide as much details as you can. Thanks

aryaxt
  • 76,198
  • 92
  • 293
  • 442

1 Answers1

3

Robotium doesn't have any knowledge of Roboguice, but you can use injection with anything that extends ActivityInstrumentationTestCase2. Before every test, you just have to "initialize your application" by getting the Application and retrieving the injector from there.

    YourApplication app = getApplication(); //YourApplication has to extend from RoboApplication
    app.setServiceModuleOverride(yourTestModule); //do this if you want to provide your overrides
    app.getInjector().injectMembers(this);
dmon
  • 30,048
  • 8
  • 87
  • 96
  • app does not have a method named "setServiceModuleOverride", and yes my application class is extending RoboApplication. any suggestions? – aryaxt Jun 22 '11 at 18:19
  • and getApplication method does not exist either? – aryaxt Jun 22 '11 at 18:19
  • 1
    I didn't have to do any of that, it applies the injection automatically my problem was somewhere else. But good to know that I have control over the injection module – aryaxt Jun 24 '11 at 01:05