title: Eclipse/Maven: JUnit tests not compiled when running them
body: <p>I am working on a project using Maven and Eclipse (m2eclipse plugin). I've got problems with the JUnit tests: </p>
  
  <p>Sometimes, when running them within Eclipse, they wont be compiled, but the old class files are used instead. When I delete the class files, I get <code>ClassNotFoundExceptions</code> in Eclipse. I then have to manually recompile them by using <code>mvn test-compile</code> or other goals. </p>
  
  <p>I also noticed that the class files of the tests sometimes are put into the <code>classes</code> subdirectory instead of <code>test-classes</code>.</p>
  
  <p>I really can't figure out what is wrong.</p>
  
  <p>The JUnit java files are within <code>src/main/java</code> and are correctly named (<code>*Test.java</code>). </p>
  
  <p>Do I have to compile and run them always via Maven? Why doesn't Eclipse compile the files when I want to run them? (Interestingly, <em>sometimes</em> it does. Sometimes everything works perfectly.)</p>