How to access files from assets folder during unit tests execution? My project is build using Gradle, I use Robolectric to run tests. It seems like gradle is being recognizing t
Updating as for Roboelectric 3.1
@Test
public void shouldGetJSONFromAsset() throws Exception{
Assert.assertNotNull(RuntimeEnvironment.application); //Getting the application context
InputStream input = RuntimeEnvironment.application.getAssets().open("fileName.xml");// the file name in asset folder
Assert.assertNotNull(input);
}
See also
de Guide