Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What's the difference between maven modules junit-jupiter-api and junit-jupiter-engine? Is it necessary to include both dependencies in build.gradle?

Do I need to provide both dependencies?

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

Or only one dependency is enough?

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
532 views
Welcome To Ask or Share your Answers For Others

1 Answer

JUnit Prior to Version 5.4

From the docs:

junit-jupiter-api

JUnit Jupiter API for writing tests and extensions.

junit-jupiter-engine

JUnit Jupiter test engine implementation, only required at runtime.

junit-vintage-engine

JUnit Vintage test engine implementation that allows to run vintage JUnit tests, i.e. tests written in the JUnit 3 or JUnit 4 style, on the new JUnit Platform.

So ...

  • You need both junit-jupiter-api and junit-jupiter-engine to write and run JUnit5 tests
  • You only need junit-vintage-engine if (a) you are running with JUnit5 and (b) your test cases use JUnit4 constructs/annotations/rules etc

JUnit from Version 5.4 Onwards

In JUnit 5.4 this is simplified, see this answer for more details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...