如何访问android测试项目中的原始资源?

ube*_*kel 6 android unit-testing android-activity

这是我的测试类:

public class AndroidTunerTest extends
        ActivityInstrumentationTestCase2<AndroidTunerActivity> {
    [...]
}
Run Code Online (Sandbox Code Playgroud)

但我无法访问我的测试项目的上下文,我只能访问我想要测试的Activity的上下文.所以我不知道如何以这里提到的相同方式阅读资源:

Android如何访问我放在res文件夹中的原始资源?

我不想在我的主应用程序中捆绑所有测试资源,因为测试包含非常大的文件,这些文件与真实应用程序无关.

我能做什么?

ube*_*kel 4

知道了...

this.getInstrumentation().getContext().getResources().openRawResource(R.raw.blah_blah);
Run Code Online (Sandbox Code Playgroud)

我花了一些时间调试和反思 ActivityInstrumentationTestCase2 继承树。