I have the following folder structure in Android Studio:
├── androidTest │ ├── java │ └── res │ └── raw │ └── test_file └── main ├──
See Android Unit Tests Requiring Context. For instrumentation test use InstrumentationRegistry.getInstrumentation().getTargetContext() (in Kotlin: getInstrumentation().targetContext). Then you can access resources. You won't need to import R file.
InstrumentationRegistry.getInstrumentation().getTargetContext()
getInstrumentation().targetContext
resources
R