简体   繁体   English

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

[英]How to default the source folder for new JUnit tests in Eclipse?

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”文件夹中创建新测试?

I use moreUnit , an Eclipse plugin to assist writing unit tests. 我使用moreUnit ,一个Eclipse插件来帮助编写单元测试。 Among other features, it lets you configure the default source folder of tests. 在其他功能中,它允许您配置测试的默认源文件夹。

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! 我同意,能够改变它会很好!

Now you can use my fast code eclipse plug-in. 现在你可以使用我的快速代码eclipse插件了。 With this plug-in you can configure the test path to be src/test/java only once. 使用此插件,您可以将测试路径配置为src/test/java一次。 It also has a jump to the unit test feature. 它还跳转到单元测试功能。 It is available at : http://fast-code.sourceforge.net/ . 它位于: http//fast-code.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM