2

I have a problem with a RoboGuice injection in POJO in tests.

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Test.class

public abstract class Test<T extends TestRequest> extends ActivityInstrumentationTestCase2<StubActivity> {

.....

    @Inject Storage mStorage;

    @Before
    public void setUp() throws Exception {

   Application applicationContext = (Application) getInstrumentation().getTargetContext().getApplicationContext();

        Injector injector = RoboGuice.overrideApplicationInjector(applicationContext, new TestModule());
        injector.injectMembers(this);

        mStorage.getIMap().clear();
// mStorage != null, but getter is null
    }



@Singleton
public class Storage {

    @Inject
    private IMap mMap;

i can't find any solutions, please help.

Gorets
  • 2,434
  • 5
  • 27
  • 45
  • I found an answer, this is a case of [Injected views are null with RG 3.0][1] [1]: http://stackoverflow.com/questions/26555970/injected-views-are-null-with-rg-3-0 – Gorets Jul 09 '15 at 09:13

0 Answers0