Is there a way of getting JUnit tests in Eclipse (specifically I'm using SpringJUnit4ClassRunner
) to use resources from src/main/resources
as well as src/test/resources
?
Maven's surefire plugin does this, but running one particular unit test from Eclipse does not.
I've got a load of Spring config in src/main/resources/spring-config/
and I want to 'override' two specific files. I've placed these test-specific overrides in src/test/resources/spring-config/
, and when running unit tests through Maven eveerything works. When I run a JUnit test from Eclipse, only the test files are available, and unsurprisingly my context fails to load.
Update
Is appears the Spring classes that configure the test context can't find the resources from src/main/resources/
when using a wildcard, but will find them if I specify them explicitly.
Doesn't find things from src/main/resources/
@ContextConfiguration(locations = {"classpath:/spring-config/*.xml"})
Does find specified files from src/main/resources/
@ContextConfiguration(locations = {"classpath:/spring-config/*.xml",
"classpath:/spring-config/app-aws.xml"})