the sample application i am working on doesn't have a resources folder in test, i don't know why, so i am trying to create the resources folder in test manually as follows:
from eclipse: on the java resources > new source folder > src/test/resources
i can see now that the resource folder appears in test package, but question is, is there's any additional configuration should i do to maven or spring or unit test so i can work with resources folder and load files from it ?
please advise, thanks.
a resource is a file in the class path folder structure for your project. this is important because your test resources will be put in your test-classes folder hierarchy and your main resources will be put in your classes folder hierarchy — both in your target folder.
You either use maven standard directory layout (then maven includes it automatically) or you point maven to the resources in your pom file in build section as follows:
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
Then you have the resources on classpath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With