The CheckOps Engineer
JUnit 5
JUnit 5 is the current JUnit for Java and the JVM: Jupiter for new tests, Platform to launch them, Vintage to run JUnit 4.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
JUnit 5 is the test framework current Java projects use. It is three pieces that share a version line. JUnit Platform launches tests and reports results to Maven Surefire, Gradle, and IDEs. JUnit Jupiter is the programming model for new tests (@Test, @ParameterizedTest, extensions). JUnit Vintage runs existing JUnit 4 tests on that platform so a codebase can migrate file by file.
The code is EPL-2.0, developed at junit-team/junit5. JUnit 5 does not start browsers, devices, or containers. Libraries such as Selenium and Testcontainers plug into Jupiter’s extension model. Assertions live in org.junit.jupiter.api.Assertions. Many teams add AssertJ on top.
Features
- Jupiter annotations:
@Test,@BeforeEach,@AfterEach,@BeforeAll,@AfterAll,@DisplayName, and@Disabled. - Parameterized tests:
@ParameterizedTestwith@ValueSource,@CsvSource,@MethodSource, and@EnumSource. - Nested tests:
@Nestedclasses group cases and share setup without a deep inheritance tree. - Tags:
@Tag("slow")plus Surefire or Gradle filters include or exclude groups in CI. - Extensions:
Extensionhooks replace most JUnit 4Rules.@TempDir,@RegisterExtension, and conditional execution (@EnabledOnOs,@DisabledIf) ship with Jupiter. - Parallel execution: Jupiter can run tests concurrently when
junit.jupiter.execution.parallel.enabledis set. Tests must tolerate that. - Vintage: JUnit 4 tests run on the Platform during a migration. New tests should not target Vintage.
- Reporting: Platform listeners emit XML and console output that CI systems already parse. The build tool, not JUnit, uploads the files.
Pros
- It is the default on the JVM: IDEs, Maven Surefire, and Gradle’s
useJUnitPlatform()treat Jupiter as the normal runner. - Migration has a supported bridge: Vintage keeps JUnit 4 tests running while new code uses Jupiter.
- Parameters are annotations, not a second framework: CSV and method sources cover tables of inputs without a custom runner class.
- Extensions are explicit: Setup is a class you can read, not a global fixture file discovered by name.
- Free: EPL-2.0. No seat license for the framework.
Cons
- Three artifacts to version: Platform, Jupiter, and (if needed) Vintage must be compatible. A BOM (
junit-bom) is the usual fix, and forgetting it causes classpath clashes. - Surefire and Gradle need a one-line switch: An old Surefire that only runs JUnit 4 reports “no tests” until
useJUnitPlatformor a current Surefire provider is set. - Parallel mode is off for a reason: Shared static state and order-dependent tests fail when it is turned on. Enabling it is a project change, not a flag you flip in CI only.
- Assertions are minimal: Jupiter’s
assertEqualsis enough, but failure messages are plainer than AssertJ. Most codebases add a second library. - Vintage is a trap if it stays forever: Leaving JUnit 4 rules in place means two extension styles in one repo.
Usage and Links (Example)
Maven:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
Import junit-bom in dependencyManagement and omit the version on the test dependency, or pin the current 5.x from Maven Central. Platform and Jupiter versions must match.
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class CalculatorTest {
@Test
void adds() {
assertEquals(2, 1 + 1);
}
}
mvn test or gradle test launches the Platform. In Gradle, the test task needs useJUnitPlatform().
Resources:
Pricing
- Free: JUnit 5 is EPL-2.0. There is no commercial JUnit edition.
- Build tools are separate: You run tests with Maven, Gradle, or Bazel. Those tools have their own licenses and CI cost.
Recommended for?
- Java and Kotlin unit tests on the JVM, including Spring Boot tests that already use
@ExtendWithor@SpringBootTest. - Codebases leaving JUnit 4, using Vintage only while files are converted.
- Integration tests that add Testcontainers or an embedded server through a Jupiter extension.
- Libraries published to Maven Central whose consumers expect
junit-jupiteras a test dependency.
Conclusion
JUnit 5 is the JVM unit framework to standardize on. Use Jupiter for new tests, the Platform so the build can see them, and Vintage only as a temporary bridge from JUnit 4. Pin the artifacts with the BOM, and treat parallel execution as a deliberate change. Browser, API, and container tooling sit beside JUnit; they are not included in it.