Issue
I need to override some properties in a JUnit test running as part of our Maven-based build. In order to do that, I need to figure out where to place the override file in our test environment. How can I determine the classpath that this line is checking when it runs in the test environment?
stream = getClass().getClassLoader().getResourceAsStream(resourceName);
I've checked the javadoc for ClassLoader but it's not terribly clear on this point.
Solution
To find the classpath, you can simply use the dependency:build-classpath plugin of maven:
mvn dependency:build-classpath -DincludeScope=test
This will give you the full classpath that it uses when running surefire. Actually, includeScope=test is the default, so you can just miss it out. Otherwise, you can specify any scope, for instance compile:
mvn dependency:build-classpath -DincludeScope=compile
Answered By - Matthew Farwell