Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath

Asked on May 10, 2021
I have a Gradle file as below, I just want to run my JUnit test classes.
build.gradle
plugins {
id 'application'
}
repositories {
mavenCentral()
}
tasks.named('test') {
useJUnitPlatform()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
}
When I run gradle clean test , it throws error.
Caused by: org.junit.platform.commons.PreconditionViolationException: Cannot create Launcher without at least one TestEngine; consider adding an engine implementation JAR to the classpath
at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:296)
at org.junit.platform.launcher.core.DefaultLauncher.<init>(DefaultLauncher.java:48)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:105)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:97)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)

Replied on May 10, 2021
You need to add junit-jupiter-engine test dependency.
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.1'
}