这是一个双重问题。
junit-vintage-engine
和junit-jupiter-engine
有什么区别?- SpringBoot 入门项目附带
junit-vintage-engine
的排除项。是强制使用junit-jupiter-engine吗?
下面是我从 Spring Initializr 生成的 SpringBoot 项目的依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
原文由 Sandeep Kumar 发布,翻译遵循 CC BY-SA 4.0 许可协议
junit-vintage-engine
用于运行 JUnit 4 测试;junit-jupiter-engine
用于 JUnit 5 测试。大概因为您将只为新的 Spring Boot 项目编写 JUnit 5 测试,所以不需要老式引擎,因此 POM 中的默认依赖项排除。
参考:
https://junit.org/junit5/docs/current/user-guide