junit-vintage-engine和junit-jupiter-engine之间的区别? [英] Difference between junit-vintage-engine and junit-jupiter-engine?

查看:580
本文介绍了junit-vintage-engine和junit-jupiter-engine之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是两个问题.

  1. junit-vintage-enginejunit-jupiter-engine有什么区别?
  2. SpringBoot入门项目带有junit-vintage-engine的排除项.是否要强制使用junit-jupiter-engine?
  1. What is the difference between junit-vintage-engine and junit-jupiter-engine?
  2. SpringBoot starter projects come with an exclusion for junit-vintage-engine. Is it to enforce the use of junit-jupiter-engine?

下面是从 Spring Initializr 生成的SpringBoot项目的依赖项:

Below is the dependency of my SpringBoot project generated from Spring Initializr:

        <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>

推荐答案

junit-vintage-engine用于运行JUnit 4测试. junit-jupiter-engine用于JUnit 5测试.

junit-vintage-engine is used for running JUnit 4 tests; junit-jupiter-engine for JUnit 5 tests.

大概是因为您将只为新的Spring Boot项目编写JUnit 5测试,因此不需要老式引擎,因此POM中的默认依赖项排除.

Presumably since you'll be writing only JUnit 5 tests for a new Spring Boot project, the vintage engine won't be needed, hence the default dependency exclusion in the POM.

参考:

https://junit.org/junit5/docs/current/user-guide

这篇关于junit-vintage-engine和junit-jupiter-engine之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆