Where can I put property files to run JUnit tests on Maven?

I am using Maven 3.0.3. I run the command "mvn test", in which my test files are in the standard location (src / test / java). Where can I put property files so that they are picked up by the Java getResourceAsStream method? I tried to place my property files in both src / main / resources and src / test / resources, but my JUnit test does not find them. This is how I want to load the tests ...

final InputStream in = getClass().getResourceAsStream("my.properties");

but it returns null. I am using JUnit 4.8. Any ideas? Thanks - Dave

+3
source share
1 answer

It works for me if I use getClass().getResourceAsStream("/my.properties").

/ , , src/test/resources/com/mycompany/mypackage/my.properties.

+5

All Articles