Build Support

There is a newer version available.
For the latest stable release, please see JUnit 6.1.3!

Gradle

Starting with version 4.6, Gradle provides native support for executing tests on the JUnit Platform. To enable it, you need to specify useJUnitPlatform() within a test task declaration in build.gradle:

test {
	useJUnitPlatform()
}

Filtering by tags, tag expressions, or engines is also supported:

test {
	useJUnitPlatform {
		includeTags("fast", "smoke & feature-a")
		// excludeTags("slow", "ci")
		includeEngines("junit-jupiter")
		// excludeEngines("junit-vintage")
	}
}

Please refer to the official Gradle documentation for a comprehensive list of options.

Aligning dependency versions

See Spring Boot for details on how to override the version of JUnit used in your Spring Boot application.

Unless you’re using Spring Boot which defines its own way of managing dependencies, it is recommended to use the JUnit Platform Bill of Materials (BOM) to align the versions of all JUnit artifacts.

Explicit platform dependency on the BOM
dependencies {
	testImplementation(platform("org.junit:junit-bom:6.0.0"))
	testImplementation("org.junit.jupiter:junit-jupiter")
	testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

Using the BOM allows you to omit the version when declaring dependencies on all artifacts with the org.junit.platform, org.junit.jupiter, and