为什么在 Maven 项目中使用 JUnit 5 时必须使用 maven-surefire-plugin?

Why is maven-surefire-plugin compulsory when using JUnit 5 in a Maven project?

我在maven项目中长期使用JUnit3和4没有maven-surefire-plugin

目前我开始尝试使用 JUnit Jupiter 包中的注释来尝试 JUnit 5 org.junit.jupiter.api。特别是 org.junit.jupiter.api.Test 被用来代替遗留的 org.junit.Test。最终,没有检测到测试,因此测试失败。

必须将 maven-surefire-plugin 添加到 pom.xml 中: ```

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
    </dependency>
</dependencies>

<build>
  <plugins>
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>${junit.platform.version}</version>
                </dependency>
        </dependencies>
    </plugin>
  </plugins>
</build>

所以特此请教:

让代码尽可能简单是我的习惯

maven-surefire-plugin 中的 Junit5 支持尚未完成,需要新版本的 maven-surefire-plugin currently being worked on