开发者

Using specific resources for android testing

I'm trying to test an android project. I'm using intellij IDEA.

So far everything goes perfect. My problem arises when I try to use a different xml resource file for the tests (with specific data for testing) instead of using the XML resource from the tested project.

I have the following directory structure:

Project

|

|---- assets

|---- res

|-------|---- values

|-------|---- xml开发者_JAVA技巧

|---- src

|---- tests

---------|----res

---------|------|-----xml

---------|-----src

I've assumed that the XML stored in the Project/tests/res/xml would automatically replace the one stored in Project/res/xml when running under the context of the test. It is not happening so, the tests keep on taking the Project/res/xml file instead of the test xml.

Do I have to make anything additional? Is there a way to somewhat mock this?

Thanks!


Certainly you can place your XML files in the resource or assets folder of your test project and access them by:

InputStream myxml = getInstrumentation().getContext().getAssets().open("my_document.xml");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜