【问题标题】:Maven is not running any testMaven 没有运行任何测试
【发布时间】:2021-03-15 02:47:51
【问题描述】:

我是第一次编写单元测试。为了在 IntelliJ 中创建测试文件,我使用快捷方式 [https://www.jetbrains.com/help/idea/create-tests.html] 创建了一个*Test.java。现在,当我尝试运行 mvn test 时,它没有运行任何测试。

pom.xml

      <dependency>
          <groupId>org.junit.jupiter</groupId>
          <artifactId>junit-jupiter</artifactId>
          <version>5.6.2</version>
          <scope>test</scope>
      </dependency>
  1. SO 我发现很少有答案是检查名称。我查了一下,文件名是&lt;classNametoTest&gt;Test.java,还可以看到文件上的JUnit符号。
  2. 我有另一个名为test 的文件夹(在根目录中)。为了验证,我尝试重命名文件夹并做了mvn clean package -> mvn test。不运行测试。
  3. Test 文件夹也在 src 中 [https://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run]

【问题讨论】:

标签: java maven unit-testing junit


【解决方案1】:

你能检查一下你是否有从org.junit.jupiter.api.Test导入的@Test

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-18
    • 2021-12-16
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 1970-01-01
    • 2015-10-19
    • 2014-02-24
    相关资源
    最近更新 更多