Complete the code to add JUnit Jupiter API as a test dependency in Gradle.
dependencies {
testImplementation '[1]'
}The correct Gradle dependency for JUnit Jupiter API is org.junit.jupiter:junit-jupiter-api:5.9.3. This adds the JUnit 5 API for writing tests.
Complete the code to apply the Java plugin in Gradle for testing support.
plugins {
id '[1]'
}junit as a plugin id, which does not exist.application or maven.The java plugin is required in Gradle to compile Java code and run tests.
Fix the error in the test task configuration to use JUnit Platform.
test {
use[1]()
}useJUnit5() which does not exist.useJUnit4() which runs only JUnit 4 tests.To run JUnit 5 tests in Gradle, you must configure the test task to use useJUnitPlatform().
Fill both blanks to add JUnit Jupiter Engine and enable test logging.
dependencies {
testRuntimeOnly '[1]'
}
test {
testLogging {
events [2]
}
}The JUnit Jupiter Engine is added as a testRuntimeOnly dependency to run tests. The testLogging.events expects a list of event names as strings, so the correct syntax is "passed", "skipped", "failed".
Fill all three blanks to configure Gradle to use JUnit 5 with correct dependencies and test task.
plugins {
id '[1]'
}
dependencies {
testImplementation '[2]'
testRuntimeOnly '[3]'
}
test {
useJUnitPlatform()
}application.useJUnitPlatform().The java plugin enables Java compilation and testing. The testImplementation dependency adds the JUnit Jupiter API for writing tests. The testRuntimeOnly dependency adds the JUnit Jupiter Engine to run the tests. The test task uses useJUnitPlatform() to run JUnit 5 tests.