Accessing application context from TestSuite in Setup() before calling getActivity()

前端 未结 6 910
太阳男子
太阳男子 2020-12-08 09:42

I have an Activity that pulls an object from an Application extended class (application context) from within the OnCreate() method.

6条回答
  •  抹茶落季
    2020-12-08 10:22

    You can call the static method for the Context:

    Context context = InstrumentationRegistry.getTargetContext();
    

    More details can be found here: https://developer.android.com/training/testing/integration-testing/index.html

提交回复
热议问题