通过VIM进行弹簧启动测试
我安装了一个Mac和Iterm2,我使用了命令vi *文件名 *.java
打开并编辑文件。该文件的单元测试在春季中使用@test
关键字注释。
如何从命令行中运行这些测试,而不是单击Intellij中的测试注释?
I have a Mac and iTerm2 installed, I used the command vi *file name*.java
to open and edit the file. This file has unit tests annotated with the @Test
keyword in Spring.
How do I run these tests from the command line instead of clicking on the Test annotation in IntelliJ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果使用maven:
要运行所有测试用例,请进入项目的根并运行(如果从其他地方运行,请使用路径)
从单个类中运行所有测试:
从测试类中运行测试用例:
如果您不使用Maven(或gradle):
请参阅:如何从命令行(没有Maven/Gradle)启动Junit 5(平台)?
edit :看起来OP无法在其设置中运行这些命令。确保您的POM中有正确的依赖关系和插件(Junit和surefire)。例如,我使用此POM创建了一个演示Maven项目(仅包括Junit和Surefire)。
这是工作MVN测试命令的屏幕截图。
If using maven:
To run all test cases, go into the project's root and run (if running from somewhere else, use the path)
To run all tests from a single class:
To run a test case from a test class:
If you are not using maven (or Gradle):
see: How to launch JUnit 5 (Platform) from the command line (without Maven/Gradle)?
EDIT: Looks like the OP is unable to run these commands in his/her setup. Make sure you have correct dependencies and plugins (Junit and SureFire) in your pom. E.g. I created a demo maven project with this pom (only including the Junit and Surefire).
Here are the screenshots of working mvn test commands.