How can we access context of an application in Robolectric?

后端 未结 14 1493
既然无缘
既然无缘 2020-12-05 03:32

Actually, I need to get a response of an API call, for that I required Context.

14条回答
  •  独厮守ぢ
    2020-12-05 04:08

    To get application context you must do the following:

    1. annotate @RunWith(RobolectricTestRunner.class)
    2. RuntimeEnvironment.application.getApplicationContext()

提交回复
热议问题