How i can install junit 5 on VSCode

孤者浪人 提交于 2020-08-10 00:37:20

问题


i'm trying to learn unit testing in java and JUnit frame but i'm on how i can and use junit on visual studio code. should i create maven project to that. i tried to import that but it does not work.


回答1:


First of all, you need to have correctly installed the Java Extention Pack in your VSCode.

Secondly, you need to download a .jar file of your preferred junit5 version. You can visit this link https://search.maven.org/artifact/org.junit.platform/junit-platform-console-standalone/1.7.0-M1/jar and download it as jar file.

After you have downloaded that file you need to add the following lines in your settings.json:

"java.project.referencedLibraries": [
    "lib/**/*.jar",
    "C:\\PathToFile\\junit-platform-console-standalone-1.6.0.jar"
]

Insert the path to the file you have downloaded.

If you have performed all the above steps correctly, you will be able to run unit tests in VSCode. Also, make sure that your test class and the methods you are testing are both public. It is advised to use the following naming convention for test class (*Test) as some users in GitHub reported problems when it was not used. Regardless that, it is considered good practice.



来源:https://stackoverflow.com/questions/60961140/how-i-can-install-junit-5-on-vscode

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