如何在Eclipse中为新的JUnit测试默认源文件夹?

时间:2022-09-11 19:43:32

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

我们的大多数Eclipse项目都有多个源文件夹,例如:

  • src/main/java
  • 的src /主/ JAVA
  • src/test/java
  • 的src /测试/ 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).

右键单击某个类并选择New JUnit Test时,新测试的默认源文件夹是“src / main / java”(可能是项目属性中列出的第一个源文件夹)。

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?

有没有办法更改新JUnit测试的默认源文件夹,这样当我执行上述操作时,默认情况下会在“src / test / java”文件夹中创建新测试?

3 个解决方案

#1


52  

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

我使用moreUnit,一个Eclipse插件来帮助编写单元测试。在其他功能中,它允许您配置测试的默认源文件夹。

#2


6  

No.

没有。

Unless you change the plugin code, the default source folder is always the same as that containing the class you right clicked on (not necessarily the first source folder listed). I agree, it would be nice to be able to change it!

除非您更改插件代码,否则默认源文件夹始终与包含您右键单击的类的文件夹相同(不一定是列出的第一个源文件夹)。我同意,能够改变它会很好!

#3


0  

Now you can use my fast code eclipse plug-in. With this plug-in you can configure the test path to be src/test/java only once. It also has a jump to the unit test feature. It is available at : http://fast-code.sourceforge.net/.

现在你可以使用我的快速代码eclipse插件了。使用此插件,您可以将测试路径配置为src / test / java一次。它还跳转到单元测试功能。它位于:http://fast-code.sourceforge.net/。

#1


52  

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

我使用moreUnit,一个Eclipse插件来帮助编写单元测试。在其他功能中,它允许您配置测试的默认源文件夹。

#2


6  

No.

没有。

Unless you change the plugin code, the default source folder is always the same as that containing the class you right clicked on (not necessarily the first source folder listed). I agree, it would be nice to be able to change it!

除非您更改插件代码,否则默认源文件夹始终与包含您右键单击的类的文件夹相同(不一定是列出的第一个源文件夹)。我同意,能够改变它会很好!

#3


0  

Now you can use my fast code eclipse plug-in. With this plug-in you can configure the test path to be src/test/java only once. It also has a jump to the unit test feature. It is available at : http://fast-code.sourceforge.net/.

现在你可以使用我的快速代码eclipse插件了。使用此插件,您可以将测试路径配置为src / test / java一次。它还跳转到单元测试功能。它位于:http://fast-code.sourceforge.net/。