In maven, any file under src/test/resources
is copied to target/test-classes
. How to access these resource files in JUnit? Using the class’s resource. It will locate the file in the test’s classpath /target/test-classes
.
URL url = this.getClass().getResource("/" + TEST_FILENAME); File file = new File(url.getFile());