Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - accessing test application assets

I've an XML file in the assets directory of my test application. I want to access this file from my suite method of the test class.

ie.,

public static TestSuite suite(){ InputStream stream = // Some code which returns the asset }

Any idea how I can do this? I tried with Resources.Resources.getSystem().getAssets() but no luck :-(. help please.

Thanx in adv, Joseph

like image 946
Joseph Avatar asked Oct 10 '10 17:10

Joseph


1 Answers

I encountered the same problem with my test app. Unfortunately, it looks like getContext() in a test case class actually returns the context of the application under test. In order to get the context of the test application itself, you have to inherit from InstrumentationTestCase and then call getInstrumentation().getContext() to get the context of the test app.

like image 183
Mike Ellery Avatar answered Sep 21 '22 06:09

Mike Ellery