I have setup an android test project that runs junit tests. It\'s using two eclipse projects \"Application\" and \"ApplicationTest\" where my tests are in the \"ApplicationT
I would suggest extending ActivityTestCase
instead of AndroidTestCase
. You can than access test project resources via
getInstrumentation().getContext().getResources().openRawResource(R.raw.your_res)
.
Dummy test case example:
public class Test extends ActivityTestCase {
public void testFoo() {
// .. test project environment
Context testContext = getInstrumentation().getContext();
Resources testRes = testContext.getResources();
InputStream ts = testRes.openRawResource(R.raw.your_res);
assertNotNull(testRes);
}
}
And then in test methods use getInstrumentation().getTargetContext()
wherever you used getContext()
in your AndroidTestCase
extension.