Java – How to default the source folder for new JUnit tests in Eclipse

eclipsejavajunitusability

Most of our Eclipse projects have multiple source folders, for example:

  • src/main/java
  • src/test/java

When you right-click on a class and choose New JUnit Test, the default source folder for the new test is "src/main/java" (presumably the first source folder listed in the project properties).

Is there any way to change the default source folder for new JUnit tests, so that when I do the above action, the new test will be created in say the "src/test/java" folder by default?

Best Answer

I use moreUnit, an Eclipse plugin to assist writing unit tests. Among other features, it lets you configure the default source folder of tests.