Intellij不运行测试 [英] Intellij does not run tests
问题描述
将我的项目导入Intellij并使其成功构建后,我正在尝试运行一些项目的测试.我导航到测试文件,然后选择运行->运行.但是,这不能运行我的测试,只是打开一个小的编辑配置"窗口,如随附的照片所示.
After importing my project into Intellij and getting it to build successfully, I am trying to run some of my project's tests. I navigate to the test file and select Run -> Run. However, this does not run my tests, just opens a small "Edit Configurations" window, as the attached photo shows.
并且,当我按照提示选择编辑配置"时,找不到JUnit.窗口如下所示.
And, when I select Edit Configurations as prompted, JUnit is not to be found. The window is shown below.
我需要做什么来运行测试?
What do I need to do to run the tests?
推荐答案
对我来说,pom.xml也是一个问题.检查 Junit5-样本pom .我注意到测试插件不见了.所以我只需要添加:
For me it was also an issue with my pom.xml. After checking Junit5-samples pom. I noticed the test plugin was missing. So I only needed to add:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
您可能还需要检查pom是否包含:
You may also want to check if your pom contains:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
这篇关于Intellij不运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!