How can we access context of an application in Robolectric?

后端 未结 14 1518
既然无缘
既然无缘 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:04

    Add

    testImplementation "androidx.test:core-ktx:${deps.testrunner}"
    

    And use:

    private val app = ApplicationProvider.getApplicationContext()
    

提交回复
热议问题