Migrating specific tests from JUnit 4 to JUnit 5 in IntelliJ

与世无争的帅哥 提交于 2019-12-05 21:49:59

问题


I am trying to migrate test files from Junit 4 to Junit 5 using IntelliJ refactor code -> migrate -> junit 4 to junit 5.

But it only run import optimization and show all unit tests in the project and ask yes or no on refactoring and nothing happens when I chose do refactor.

any one know on another migration tool / plug in or a way to make the migration work ?


回答1:


Jeanne Boyarsky created a tool to convert JUnit 4 based tests to JUnit Jupiter.

You can find it in her GitHub account: https://github.com/boyarsky/convert-junit4-to-junit5




回答2:


It seems that converting test from JUnit 4 to JUnit 5 in IntelliJ 2017.3 is not complete. As suggested by Sam Brannen there is a small application on Github called convert-junit4-to-junit5 that can do the job.

Just clone the Github repo and build the software using Maven mvn clean package. Then run the the application using

java -jar \
     <path-to-your-cloned-repo>/convert-junit4-to-junit5/target/convert-junit4-to-to-junit5-0.0.1-SNAPSHOT.jar \
     <path to where your JUnit 4 tests are located>

For further instruction please read the projects documentation.



来源:https://stackoverflow.com/questions/46882930/migrating-specific-tests-from-junit-4-to-junit-5-in-intellij

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!