I'm trying to write a unit test which uses mock JSON responses.
Basically, my intent was to add the json files to /res/raw, and access them using the same method I would within the application:
InputStream jsonStream = context.getResources().openRawResource(R.raw.mock_json_response)
But when I do this I get the following error:
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f060001
I'm using robolectric for testing - I'm not sure if that changes the way in which external files would have to be accessed.
I've tried putting the JSON file in both /app/src/main/res
and /app/src/test/res
but neither seems to work.
Is it possible to access resources in a test in this way?