1

For my tests, I want to use some assets which are only used for testing, e.g. a json file called bundle1.json. I moved this file in the in the folder src/androidTest/assets:

enter image description here

However, when I try to load the file bundle1.json:

getContext().getResources().getAssets().open("bundle1.json");

I get a FileNotFoundException. Do I have to change my build.gradle?

Erik
  • 11,944
  • 18
  • 87
  • 126

1 Answers1

0

I ended up using the class loader:

InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("assets/bundle1.json");
Erik
  • 11,944
  • 18
  • 87
  • 126