Search code examples
javaspring-bootjunitspring-boot-test

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?
  2. SpringBoot starter projects come with an exclusion for junit-vintage-engine. Is it to enforce the use of junit-jupiter-engine?

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>

Solution

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

    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.

    Reference:

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