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:
Until today I could open a JUnit test source file and select
Run as | JUnit test
from the toolbar. Before I migrated to Maven, Eclipse built the unit test when needed.Since Maven, I get a
ClassNotFoundException
in case I have not explicitly compiled the tests before. I can bypass this if I select the POM and doRun as | Maven test
. This will compile the tests and run all tests.If I select the unit test again and choose
Run as | JUnit test
from the toolbar now, it'll execute the test.
Since this is way too unconvenient, I'd like the "old" behavior back and I think this should only be a configuration problem.
I have
- read Running a single test in Eclipse, but it describes a problem without Maven. Basically, the expected behavior is what I had before.
- read Running JUnit tests with Maven under Eclipse is what I currently have. I have Surefire and I can run all the tests when selecting the POM.
- my Surefire version is 2.18
- converted my project's directory structure to the default Maven layout (which it wasn't before)
- Running a single test in Maven - No tests were executed is not applicable, because I want to run tests from Eclipse, not from command line.
- [x] Build autmatically enabled
- [x] Maven project Builder is configured in project properties
- The mailing list stops unresolved
- read about Surefire arguments
I'm giving up now.
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?