title: What is the correct way to write to temp file during unit tests with Maven?
body: <p>I have written a unit test that writes a file to the file-system, given no path it writes to the working directory; so if executed from the project directory it writes in the project root, if in the projects parent directory it writes to the parents root directory.</p>
  
  <p>So what is the correct way to write to the target directory? Quite possibly a directory inside the target directory?</p>
  
  <p>If I quite simply specify <code>target/</code> with the file it will write to the parent projects target instead of the projects target.</p>
  
  <p><strong>UPDATE</strong>: I actually want the file after the test finishes. The file is for an extraction format for third-parties that needs to be sent to the third parties. The test can be switched on/off to allow me to only run if the format of the file changes for re-approval. It's not a huge problem where the file goes, but I would like something that's easy to find.</p>