Android Mocking a Dagger2 injected dependency for a Espresso test

后端 未结 3 2083
太阳男子
太阳男子 2021-02-15 11:40

I have a heavily dependency injected (dagger2) application. I would like to run an espresso test without having the test navigate through the whole application

3条回答
  •  半阙折子戏
    2021-02-15 12:43

    there is no value set in

    LoginStateManager

    so when you build the component you get both TelePresenter Dependency and LoginStateManager dependency but no values set in member variables of the both .So i think you need to set the values of member variables before accessing them.

    getBaseLoginResponse().getAccessToken())
    

    the above line of code is giving you null because you haven't set the value .So before accessing it you need to set the values first

提交回复
热议问题