I am trying to do maven test.
I have set resource directory
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
I put a folder called inbound inside this directory. In my junit, I am trying to open it as new File("Inbound"), but it always cannot find it. I have have a inbound copy under my project root. The junit code cannot find it. Could any one please give me some suggestion? Thank you
If you use src/test/resources, then you don't have to specify it in your pom.xml as it is the default resources path for tests.
Regarding your problem, you should not use new File("myfile"); but MyTestClass.class.getResourceAsStream("/myfile"); instead.
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