开发者

How can I access raw resources in android test projects?

开发者 https://www.devze.com 2023-03-29 10:57 出处:网络
This is my test class: public class AndroidTunerTest ext开发者_运维百科ends ActivityInstrumentationTestCase2<AndroidTunerActivity> {

This is my test class:

public class AndroidTunerTest ext开发者_运维百科ends
        ActivityInstrumentationTestCase2<AndroidTunerActivity> {
    [...]
}

But I can't access the context of my test project, I can only access the context of the Activity I want to test. So I don't know how to read the resources in the same way mentioned here:

Android how to get access to raw resources that i put in res folder?

I don't want to bundle all the test resources in my main app because the testing has very big files which aren't relevant for the real app.

What can I do?


Got it...

this.getInstrumentation().getContext().getResources().openRawResource(R.raw.blah_blah);

Took me a bit of debugging and introspecting the ActivityInstrumentationTestCase2 inheritance tree.

0

精彩评论

暂无评论...
验证码 换一张
取 消