There is a known bug in Android Studio, where application resources are not available from the test classes.
The solution according to the above thread should contain the following lines in build.gradle:
task copyTestResources(type: Copy) { from "${projectDir}/src/test/resources" into "${buildDir}/classes/test" } processTestResources.dependsOn copyTestResources
but gradle says:
Error:(132, 0) Could not find property 'processTestResources' on project ':app'.
Where exactly do I need to put the line
processTestResources.dependsOn copyTestResources
inside my build.gradle?
EDIT:
I have not had apply plugin: 'java' in my build files yet. The problem is that in the module of my app gradle module I already have apply plugin: 'android' and try to add java plugins to
Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.
I tried puttin apply plugin: 'java' in the top level assembly file and then
task copyTestResources(type: Copy) { from "${projectDir}/app/src/test/resources" into "${buildDir}/classes/test" }
Notice that I added the module directory to the line. This is great, but unit tests that require access to resources still do not work.
source share