title: How to deal with relative path in Junits between Maven and Intellij
body: <p>I have a maven project with a module</p>
  
  <pre><code>/myProject
  pom.xml
      /myModule
      pom.xml
         /foo
         bar.txt
  </code></pre>
  
  <p>Consider a Junit in <em>myModule</em> which needs to open <em>bar.txt</em>, with maven the basedir is the module directory.</p>
  
  <p>So to open the file <em>bar.txt</em>  :</p>
  
  <pre><code>  new File("foo/bar.txt")
  </code></pre>
  
  <p>This works well when you execute <code>mvn test</code> <strong>BUT</strong> when you launch the same junit in <strong>intellij</strong>, it fails because Intellij sets the basedir in the project directory, not the module directory. </p>
  
  <p>Intellij tries to open <code>myProject/foo/bar.txt</code> instead of <code>myProject/myModule/foo/bar.txt</code></p>
  
  <p>Is there a way to deal with that ?</p>