Difference between junit-jupiter-api and junit-jupiter-engine

What is the difference between maven junit-jupiter-apiand modules junit-jupiter-engine? Do I need to include both dependencies in build.gradle?

Do I need to write both dependencies like

testCompile("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
testCompile("org.junit.jupiter:junit-jupiter-api:${junitVersion}")

or

testCompile("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")

enough?

And do I need to add a dependency on junit-vintage-engine?

+26
source share
4 answers

JUnit to version 5.4

From the docs :

junit-jupiter-api

JUnit Jupiter API for writing tests and extensions.

junit-jupiter-engine

The implementation of the JUnit Jupiter engine is only required at runtime.

junit-vintage-engine

Implementation of the JUnit Vintage testing mechanism, which allows you to run old JUnit tests, i.e. tests written in the style of JUnit 3 or JUnit 4 on the new JUnit platform.

So...

  • JUnit5 junit-jupiter-api junit-jupiter-engine
  • junit-vintage-engine , (a) JUnit5 (b) JUnit4 constructs/annotations/rules ..

JUnit 5.4

JUnit 5.4 , . .

+25

, junit-jupiter-api junit-jupiter-engine Maven. junit-jupiter-engine , . , Gradle . https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine/5.1.1

+10

junit-jupiter

JUnit 5.4 Maven, JUnit 5. junit-jupiter.

<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.4.2</version>
    <scope>test</scope>
</dependency>

:

:

  • JUnit---1.4.0.jar
  • JUnit- 1.4.0.jar

- , JUnit 5 Jupiter.

JUnit 3 4, , JUnit Vintage Engine, junit-vintage-engine. IBM.

<!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine -->
<dependency>
    <groupId>org.junit.vintage</groupId>
    <artifactId>junit-vintage-engine</artifactId>
    <version>5.4.2</version>
    <scope>test</scope>
</dependency>
+9

junit-team/junit5-samples. junit5--- Gradle Gradle junit5--- Maven Maven.

As you can see in both examples, the only dependency needed is this junit-jupiter.

+1
source

Source: https://habr.com/ru/post/1692723/


All Articles