Test classes/resources should come before the main classes/resouces in the runtime classpath of a test
The runtime classpath of a unit test of a gradle project in Eclipse usually lists the main classes and resources (bin/main) before the test classes and resouces (bin/test). This is in contrast to plain gradle and maven on the command line as well as m2e, where the test classes/resources come before the main classes/resources.
A use case where this is relevant is to have named classpath resources overridden for tests, e.g., a config file or a template. Note that this is different from having a test configuration with annotations such as Spring's @Primary to actively prioritize the test configuration, which was addressed in the separation/filtering of main and test classpaths in release 2.2.0. This issue concerns the order of classpath entries for tests.
This sample project demonstrates the issue: /gradlew test succeeds whereas running the test in Eclipse fails.
Note that manually moving any <classpathentry output="bin/test"> element before the first <classpathentry output="bin/main"> element in .classpath makes the test pass in Eclipse.
Here's another SO user running into this.
I had a quick look at how m2e achieves the intended behavior. It defines a custom runtime classpath provider who sets the classpath for the tests in the order explained above. I think we can do the same for Buildship too.
Any progress on this? It looks like this causes test runs to fail in VSCode (see vscode-java-test - The property file in src/test/resources is not recognized and the test fails)