Load instrumentation test local files

Sometimes you might need to add setup files (json/xml/.properties/etc.) to your instrumentation tests (androidTest) and load them in your tests.

One way to do that is to add them to the assets directory.

Add the assets directory to your src/androidTest path and under it you can add your files. It should look like this: src/androidTest/assets/your_file_here

To access the files from your instrumentation tests you can use the context and then resources and assets like this:

InstrumentationRegistry.getInstrumentation().context.resources.assets.open("your_file_name")
keyboard_arrow_up
sponsored
Exit mobile version