简体   繁体   English

如何在 Intellij Idea 中自动移动单元测试类?

[英]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.

相关问题 Java:如何在Idea Intellij中将类移动到另一个包? - Java: How to move classes to another package in Idea Intellij? 如何在IntelliJ IDEA中未经测试列出所有类? - How to list all classes without test in IntelliJ IDEA? IntelliJ Idea - 将每个内部静态类移动到自己的文件 - IntelliJ Idea - Move each inner static classes to own file 如何在 Intellij Idea 12 中重命名/移动项目? - How to rename / move a project in Intellij Idea 12? 如何在 IntelliJ IDEA 中自动拆分长字符串? - How to split long strings in IntelliJ IDEA automatically? 如何在 Intellij Idea 中找到所有未使用的类? - How find all unused classes in Intellij Idea? 使用多个测试目录在 intellij idea 中自动创建测试 - Automatically creating tests in intellij idea with multiple test directories 如何在Intellij IDEA中更改默认测试框架? - How to change default test framework in Intellij IDEA? 如何找到IntelliJ Idea中具有最多依赖类的类? - How to find out classes with highest number of dependent classes in IntelliJ Idea? 除了使用集成测试运行器在IntelliJ IDEA项目中以“IntegrationTest”结尾的所有JUnit单元测试之外,我该如何运行? - How can I run all JUnit unit tests except those ending in “IntegrationTest” in my IntelliJ IDEA project using the integrated test runner?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM