简体   繁体   English

junit-vintage-engine 和junit-jupiter-engine 的区别?

[英]Difference between junit-vintage-engine and junit-jupiter-engine?

It's a two-fold question.这是一个双重问题。

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

Below is the dependency of my SpringBoot project generated from Spring Initializr :下面是我从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>

junit-vintage-engine is used for running JUnit 4 tests; junit-vintage-engine用于运行 JUnit 4 测试; junit-jupiter-engine for JUnit 5 tests. junit-jupiter-engine用于 JUnit 5 测试。

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.大概因为您将只为新的 Spring Boot 项目编写 JUnit 5 测试,所以不需要老式引擎,因此 POM 中的默认依赖项排除。

Reference:参考:

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

Answer : 1. Based on reading i found some difference like,答:1.根据阅读,我发现了一些不同之处,例如,

junit-vintage-engine : junit-vintage-engine :

  • Used in Junit-4 Testing.用于 Junit-4 测试。
  • Used to call core classes and annotations.用于调用核心类和注解。
  • 'Assert' which provide assertion methods for performing test. 'Assert' 提供用于执行测试的断言方法。
  • 'Assume' used to place assumptions. “假设”用于放置假设。
  • Use annotation like, @Ignore, @Before, etc...使用注释,如@Ignore、@Before 等...

junit-jupiter-engine : junit-木星引擎:

  • Used in Junit-5 Testing用于 Junit-5 测试
  • Provide some API which helpful to write test cases.提供一些有助于编写测试用例的 API。
  • 'Assertions' provides utility methods of assertion condition for testing. “断言”提供了用于测试的断言条件的实用方法。
  • 'Assumptions' - utility method provide condition based on assumption. '假设' - 效用方法提供基于假设的条件。
  • Change the bit of annotation name like, @Disable, @BeforeAll, @BeforeEach, etc...更改注释名称的位,例如@Disable、@BeforeAll、@BeforeEach 等...

Answer : 2. I'm also amazed they are still providing older vintage library probably there is some reason which i don't know till now but based on current usage we'll see that in next update.回答: 2.我也很惊讶他们仍然提供较旧的老式图书馆,可能有一些我现在还不知道的原因,但根据当前的使用情况,我们将在下一次更新中看到这一点。

Have a nice day!!!祝你今天过得愉快!!! :) :)

First question is also related with the version of JDK.第一个问题也和JDK的版本有关。 To be able to use jupiter engine, you must have Java 8 or higher.为了能够使用 jupiter 引擎,你必须有 Java 8 或更高版本。 For second question;对于第二个问题; since the vintage engine is for JUnit4 and JUnit4 is greater than 10 years old, it is not recommended to be used.由于老式引擎是针对 JUnit4 的,而 JUnit4 已经有超过 10 年的历史了,所以不建议使用。 As far as I know, it has not been updated along this time although java has been evolved so much.据我所知,虽然java已经进化了这么多,但这次并没有更新。 I think that is why spring initializers enforce the use of junit-jupiter-engine.我认为这就是 spring 初始化程序强制使用 junit-jupiter-engine 的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 junit-jupiter-api 和 junit-jupiter-engine 的区别 - Difference between junit-jupiter-api and junit-jupiter-engine 找不到 arguments [org.junit.jupiter:junit-jupiter-engine] 的方法 testRuntime() - Could not find method testRuntime() for arguments [org.junit.jupiter:junit-jupiter-engine] JUnit 5 老式引擎 JUnit 4 错误:不支持版本的 junit:Z587FEZDE8 404B832.CDDC58 404B8E3505 请升级到 4.12 或更高版本。 如何降级? - JUnit 5 vintage engine for JUnit 4 error: Unsupported version of junit:junit: 4.11. Please upgrade to version 4.12 or later. How to downgrade? Maven Surefire 插件执行 JUnit 4 测试,即使 JUnit Vintage Engine 不在 Maven 项目中 - Maven Surefire plugin executes JUnit 4 tests, even though the JUnit Vintage Engine is not in Maven the project JUnit 5 - 使用JUnit Jupiter引擎时IntelliJ IDEA中的空测试套件 - JUnit 5 - Empty test suite in IntelliJ IDEA when using JUnit Jupiter engine 如何确定使用JUnit Vintage与JUnit Jupiter运行哪些测试 - How to determine which tests were run using JUnit Vintage vs. JUnit Jupiter 用于测试我的 API 客户端的 JUnit 测试不起作用,“错误:ID 为‘junit-jupiter’的测试引擎无法执行测试” - JUnit test for testing my API client is not working, "Error: Test Engine with ID 'junit-jupiter' failed to execute test" IntelliJ + JUnit 5(木星) - IntelliJ + JUnit 5 (Jupiter) JUnit3和JUnit4之间在性能上有区别吗? - Is there a performance difference between JUnit3 and JUnit4? Junit 3,Junit 4,TestNG和有什么不一样 - what is the difference between Junit 3, Junit 4, TestNG
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM