I'm having a problem where IntelliJ 13.1.4, when running a unit test, can't find a ServiceLoader
file in the src/test/resources
directory of my module.
Please note before answering that I've done all of the following:
gradle test
the unit test runs fine.src/test/resources
directory is marked as being a test resources directory. (See screenshot below.)build/classes/test/
and build/classes/java
directories, but neither build/resources/test/
nor build/resources/main/
.Any ideas on what else could be causing IntelliJ to fail here?
Screenshot of my module configuration, showing the Test Resource Folders setting.
I managed to get it working better by creating a test-resources
directory parallel to the test
directory (!).
Still seeing intermittent problems with this, though. Those times, it's possible to open the IntelliJ project settings and define the test resources as source instead (the Gradle project will remain unchanged).
Must be an IntelliJ bug, as I've experienced the same thing in Android Studio.
EDIT:
I found a workaround to the issue.
Add the following at the end of the Gradle config (and specify your test resources path):
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources