I have a problem with my tests in Maven and Eclipse.
I run my test suite from Eclipse and all works well, but when I run
mvn test
I have an exception and it appears when I'm trying to read some files in test cases like this:
final File javaFolder = new File("WEB-INF/test/file");
When I do that I have a Null Pointer Exception and debugging I saw that the path is
C:\Users\myUser\AppData\Local\Temp\WEB-INF\test\file
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:
<testSourceDirectory>WEB-INF/test/java</testSourceDirectory>
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
getClass().getResource("myFile").getFile()
but when I printed the absolute path I had C:\Users\myUser\AppData\Local...\myFile
again
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.
In addition, when I print my "user.dir" I have: C:\Users\myUser\AppData\Local\Temp
Edit2: my project path is in another partition E:\work\myProject