IntelliJ IDEA does correctly handle resources for non-default test source sets
This is support request 54018
-
Clone this repository: https://github.com/tomwhoiscontrary/minimal-resource-bug
-
In the shell, navigate to the clone
-
Run ./gradlew test
-
Run ./gradlew bug
-
In IDEA, do File > Open, and select the clone
-
In the Import Project from Gradle dialog which appears, ensure that the path to the build.gradle is correct, and that the 'use default gradle wrapper' option is selected
-
Do File > Project Structure and ensure an SDK is selected
-
Note that in the Project view, and in the Project Structure dialog, both src/test/resources and src/bug/resources are marked as test resource folders
-
Open the src/test/java directory, open the context menu for the LoadTestResource class, and select Run (run it as a plain TestNG test if you have a choice)
-
Open the src/bug/java directory, open the context menu for the LoadBugResource class, and select Run (run it as a plain TestNG test if you have a choice)
-
Expected: all tests pass in Gradle, all tests pass in IDEA
-
Actual: all tests pass in Gradle, the test in src/test passes in IDEA, the test in src/bug fails in IDEA
Doing a rebuild or a clean make of the project in IDEA produces the following files in the build directory:
- build/classes/test/LoadBugResource.class
- build/classes/test/LoadTestResource.class
- build/resources/test/test.txt
Some debugging reveals that during execution of the test in src/bug, the classloader has the following build output directories on its classpath:
- build/classes/test
- build/resources/test
- build/resources/main
It appears that IDEA is simply not processing resources in the src/bug/resources directory.