title: Running single JUnit4 test in Eclipse with Maven
body: <p>When writing tests, I'd like to run them individually. Howver, since I have switched from the default Eclipse Java builder to Maven, this is not possible any more. Observations:</p>
  
  <ol>
  <li><p>Until today I could open a JUnit test source file and select <code>Run as | JUnit test</code> from the toolbar. Before I migrated to Maven, Eclipse built the unit test when needed. </p></li>
  <li><p>Since Maven, I get a <code>ClassNotFoundException</code> in case I have not explicitly compiled the tests before. I can bypass this if I select the POM and do <code>Run as | Maven test</code>. This will compile the tests and run all tests.</p></li>
  <li><p>If I select the unit test again and choose <code>Run as | JUnit test</code> from the toolbar now, it'll execute the test.</p></li>
  </ol>
  
  <p>Since this is way too unconvenient, I'd like the "old" behavior back and I think this should only be a configuration problem.</p>
  
  <p>I have</p>
  
  <ul>
  <li>read <a href="https://stackoverflow.com/questions/646307/running-a-single-junit-test-in-eclipse">Running a single test in Eclipse</a>, but it describes a problem without Maven. Basically, the expected behavior is what I had before.</li>
  <li>read <a href="https://stackoverflow.com/questions/5451808/running-junit-tests-with-maven-under-eclipse">Running JUnit tests with Maven under Eclipse</a> is what I currently have. I have Surefire and I can run all the tests when selecting the POM.</li>
  <li>my <a href="https://stackoverflow.com/questions/26979620/maven-with-surefire-refuses-to-run-single-test-method">Surefire version is 2.18</a></li>
  <li>converted my project's directory structure to the default Maven layout (which it wasn't before)</li>
  <li><a href="https://stackoverflow.com/questions/4646014/running-a-single-test-in-maven-no-tests-were-executed">Running a single test in Maven - No tests were executed</a> is not applicable, because I want to run tests from Eclipse, not from command line.</li>
  <li>[x] Build autmatically enabled</li>
  <li>[x] Maven project Builder is configured in project properties</li>
  <li>The <a href="https://dev.eclipse.org/mhonarc/lists/m2e-users/msg03823.html" rel="noreferrer">mailing list</a> stops unresolved</li>
  <li>read about <a href="https://stackoverflow.com/questions/12392926/maven-surefire-arguments-when-running-junit-test-via-eclipse">Surefire arguments</a></li>
  </ul>
  
  <p>I'm giving up now. </p>
  
  <p><strong>How can I do efficient red-green refactoring, i.e. run only one unit test at a time without adding a run configuration for each single test?</strong></p>