Maven - Override test resource folder
<p>I have a problem with my tests in Maven and Eclipse.</p>

<p>I run my test suite from Eclipse and all works well, but when I run </p>

<pre><code>mvn test
</code></pre>

<p>I have an exception and it appears when I'm trying to read some files in test cases like this:</p>

<pre><code>final File javaFolder = new File("WEB-INF/test/file");
</code></pre>

<p>When I do that I have a Null Pointer Exception and debugging I saw that the path is </p>

<pre><code>C:\Users\myUser\AppData\Local\Temp\WEB-INF\test\file
</code></pre>

<p>In addition, I think that is important to say that I overwrote the test directory in my pom, because we need test sources in a special place. We did it in this way:</p>

<pre><code>&lt;testSourceDirectory&gt;WEB-INF/test/java&lt;/testSourceDirectory&gt;
</code></pre>

<p>So my question is: Why running tests with Maven is not getting the correct working directory? Could I define a specific folder to read some files? I tried with things like </p>

<pre><code>getClass().getResource("myFile").getFile() 
</code></pre>

<p>but when I printed the absolute path I had <code>C:\Users\myUser\AppData\Local...\myFile</code> again</p>

<p>Edit: I don't have a chance to follow the convention because I'm talking about a big system that has never used Maven so can't change all the directory structure. It is not my desition, sadly. </p>

<p>In addition, when I print my "user.dir" I have: <code>C:\Users\myUser\AppData\Local\Temp</code></p>

<p>Edit2: my project path is in another partition <code>E:\work\myProject</code></p>