The Testing in Java & JVM projects documentation suggests the following dependencies.
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
However, my testing shows that only junit-jupiter is required in order to run unit tests:
- via the Gradle test task
- in IntelliJ IDEA
Here’s my example build.gradle.kts.
plugins {
java
}
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
What am I missing here? Why is junit-platform-launcher a suggested dependency, when it’s not required to run tests?