如何在Android测试中访问测试和应用程序上下文?

时间:2014-07-08 08:52:55

标签: android android-testing

我需要在测试中访问测试和应用程序Context。我无法找到允许执行此操作的Android测试类型(InstrumentationTestCaseAndroidTestCase ...)。任何提示?

1 个答案:

答案 0 :(得分:2)

终于找到了它。将InstrumentationTestCase与:

一起使用
  • getInstrumentation()。getContext():获取测试上下文
  • getInstrumentation()。getTargetContext():获取目标应用程序上下文
相关问题