Search code examples
androidtestinginstrumented-test

How to load all test resources without using names in Android?


In my androidTest/resources directory I have a few hundreds of images. I want to read all of them in a loop and test against specific function. I don't want to use their names, as often I don't know them. Is there any possibility to load by regex or iterate through the directory?


Solution

  • I found a solution. Change the name of directory from resources to assets and then use InstrumentationRegistry.getInstrumentation().context.resources.assets.list("")