I’m using Eclipse Kepler and Maven 3.2.3. I have imported my projects using the M2Eclipse plugin. Normally, when I run a JUnit test on the command line, like
mvn clean test -Dtest=MyJunitTest
there are some things that run in the “process-resources” and “process-classes” phases before my test is executed. In Eclipse, when I open the JUnit test file in an editor, right click the class name (e.g. “MyJUnitTest”) and right click on “Run As” and “JUnit Test”, those phases do not seem to be getting run. So my question is, how can I make right-clicking on my Junit Test and selecting “Run As” -> “JUnit Test” behave as if I had typed “mvn clean test -Dtest=MyJunitTest” on the command line?
Maven and JUnit are two completely different tools, each with a different build - run path and each with different requirements. Just because Maven can utilize JUnit as part of it's toolchain, does not mean they are the same!
You apparently made your project dependent on the Maven build path. It would be extremely difficult, or maybe outright not possible, to make JUnit follow that path.
In Eclipse, with the m2e plugin, it is trivial to create custom runs, using the Run As > Maven build. Documentation is available if you need it.
This "Maven build" option is available only from top level of your project, where your pom is located. You will then have to specify all your options, such as
-Dtest=MyJunitTest
.