I have a maven project that loads an xslt file and executes the transformation along with other processing on the result. Normally when the user runs the application, the us
My problem is that I want to run tests against those xslt files in testing phase. How can I achieve this?
There is nothing to do, target/classes is on the class path of tests. More precisely, the class path for tests is:
target/test-classestarget/classesdependenciesSo resources from src/main/resources (which are copied into target/classes) are visible from tests.
If you put a file foo.txt inside src/test/resources/, you can open this via:
// try-with-resource (Java 1.7)
try (InputStream is = getClass().getClassLoader().getResourceAsStream("foo.txt")) {
// do something with is...
}
You can also take a look at the maven-resources-plugin.