[英]How to move Unit Test classes automatically in Intellij Idea?
Is there any way, how to make Intellij Idea to move my Unit Test classes automatically to a coresponding package when I move tested class?有什么办法,当我移动测试类时,如何让 Intellij Idea 自动将我的单元测试类移动到相应的包?
For example I have these two classes:例如我有这两个类:
src/main/java/com/MyClass.java
src/test/java/com/MyClassTest.java
When I move当我移动
src/main/java/com/MyClass.java
to到
src/main/java/com/subpackage/MyClass.java
I need the test class to be moved automatically like this:我需要像这样自动移动测试类:
src/test/java/com/subpackage/MyClassTest.java
It is the same functionality, that does MoreUnit Eclipse plugin.这是与 MoreUnit Eclipse 插件相同的功能。
Intellij Idea does not support this so far. Intellij Idea 目前不支持这一点。
You can vote here for a new idea to make this feature happen.您可以在此处投票支持实现此功能的新想法。 https://youtrack.jetbrains.com/issue/IDEA-20779#tab=Comments&u=1481384491786 https://youtrack.jetbrains.com/issue/IDEA-20779#tab=Comments&u=1481384491786
Edit 2018: Intellij Idea now contains this functionality. 2018 年编辑:Intellij Idea 现在包含此功能。
Edit 2018-08: It seems that it does not work anymore or it never worked and I just thought it worked.编辑 2018-08:它似乎不再起作用或从未起作用,我只是认为它起作用了。
I use Intellij 14.0.2 (what version do you use ?), and its not part of the refactor functionality.我使用 Intellij 14.0.2(你使用什么版本?),它不是重构功能的一部分。 Im afraid you will also have to go to your Test class and refactor a move on it also.恐怕您还必须去您的 Test 课程并对其进行重构。
If this is a feature yo would like to see you can riase a request.如果这是您希望看到的功能,您可以提出请求。 In doing so you might actually find the functionality is actually in it , just hard to find.在这样做时,您实际上可能会发现功能实际上就在其中,只是很难找到。
https://intellij-support.jetbrains.com/hc/en-us/requests/newhttps://intellij-support.jetbrains.com/hc/en-us/requests/new
On IntelliJ 2021.1 automatic Test Unit Class package move as the Source Class move to another package does not work.在IntelliJ 2021.1自动测试单元类包移动,因为源类移动到另一个包不起作用。
The only way that I've found for this to work was to install the plug-in UnitVisualizer .我找到的唯一方法是安装插件UnitVisualizer 。 After installing the plug-in as the Source Class moves from one package to another also the respective Test Unit Class moves to the same package on the test directory.安装插件后,随着源类从一个包移动到另一个包,相应的测试单元类也会移动到测试目录中的同一个包。 Also bulk classes package moves also work with the plug-in.此外,批量类包移动也可以与插件一起使用。
The link to the plug-in : https://plugins.jetbrains.com/plugin/10493-unitvisualizer插件链接: https : //plugins.jetbrains.com/plugin/10493-unitvisualizer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.