JUnit 5 is the current generation of the most widely used Java testing framework. It is not one library but three modules: the JUnit Platform that launches tests, JUnit Jupiter that provides the annotations and API you write tests with, and JUnit Vintage that runs old JUnit 3 and 4 tests. Understanding this junit 5 architecture explains why a Maven or Gradle project needs specific dependencies and how other test engines plug in.
JUnit 5 requires Java 8 or newer at runtime, and recent 5.x and 6 releases are used with current LTS versions such as Java 21 and 25.
The name "JUnit 5" is shorthand for this composition:
| Module | Role | You use it to |
|---|---|---|
| JUnit Platform | Foundation that discovers and launches test engines, and defines the TestEngine API | Run tests from IDEs, Maven, Gradle and the console |
| JUnit Jupiter | The programming model (annotations, assertions) plus the engine that runs Jupiter tests | Write new tests |
| JUnit Vintage | An engine that runs JUnit 3 and 4 tests on the Platform | Migrate old test suites gradually |
Each module has its own artifact. Jupiter is split further into junit-jupiter-api (what you compile against), junit-jupiter-engine (what runs the tests, needed only at runtime) and junit-jupiter-params (parameterized tests). The aggregate junit-jupiter artifact brings all three.
When you run tests from a build tool or IDE, the following happens:
Launcher.TestEngine found on the classpath to discover tests that match the request (a package, a class or a tag, for example).Because the Platform only talks to the TestEngine interface, other frameworks can run on it too. Some third-party engines, such as the ones for Spock or Cucumber, do exactly that.
Jupiter's test API uses annotations from the org.junit.jupiter.api package:
Test classes and methods do not need to be public; package-private is enough, and a test method must not be private or static.
JUnit 4 had runners and rules, which could not be combined well. Jupiter replaces them with one extension model. You register an extension with @ExtendWith, and it can hook into lifecycle events, resolve method parameters, handle exceptions and decide whether a test runs at all. For example, the Mockito and Spring integrations are extensions.
Use the bill of materials (BOM) so all JUnit artifacts share one version:
Check Maven Central for the newest release before copying the version number. Also use a recent Maven Surefire plugin (3.x), because older Surefire versions do not run JUnit Platform tests.
| JUnit 4 | JUnit 5 (Jupiter) |
|---|---|
@Before, @After | @BeforeEach, @AfterEach |
@BeforeClass, @AfterClass | @BeforeAll, @AfterAll |
@Ignore | @Disabled |
@Category | @Tag |
@RunWith, @Rule | @ExtendWith |
org.junit.Assert | org.junit.jupiter.api.Assertions |
To keep old tests running while you migrate, add junit-vintage-engine next to Jupiter. Both engines then run in the same build, and you can convert test classes one at a time. Remove Vintage when no JUnit 4 tests remain.
Jupiter also adds features JUnit 4 lacked: nested test classes with @Nested, parameterized tests, dynamic tests, conditional execution annotations such as @EnabledOnOs, and constructor and method parameter injection.
JUnit 5 is the whole project. Jupiter is the part with the new API and engine that you write tests against.
No. Vintage exists only to run JUnit 3 and 4 tests. A new project needs just Jupiter.
Yes, by adding the Vintage engine. Both kinds of tests run in one build.
Usually the Surefire plugin is too old, or junit-jupiter-engine is missing from the test classpath. Use Surefire 3.x and the junit-jupiter dependency.
JUnit 5 is built from the Platform (launcher and engine API), Jupiter (the API and engine for new tests) and Vintage (support for JUnit 3 and 4). Tests are discovered by engines through the Launcher, extensions replace runners and rules, and a Maven BOM keeps versions aligned. New projects need only Jupiter.