0
0
JUnittesting~10 mins

Gradle dependency setup in JUnit - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add JUnit Jupiter API as a test dependency in Gradle.

JUnit
dependencies {
    testImplementation '[1]'
}
Drag options to blanks, or click blank then click option'
A"org.junit.jupiter:junit-jupiter-api:5.9.3"
B"junit:junit:4.13.2"
C"org.mockito:mockito-core:4.8.0"
D"org.testng:testng:7.7.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using JUnit 4 dependency instead of JUnit Jupiter.
Forgetting to put the dependency string in quotes.
2fill in blank
medium

Complete the code to apply the Java plugin in Gradle for testing support.

JUnit
plugins {
    id '[1]'
}
Drag options to blanks, or click blank then click option'
A"application"
B"maven"
C"junit"
D"java"
Attempts:
3 left
💡 Hint
Common Mistakes
Using junit as a plugin id, which does not exist.
Using unrelated plugins like application or maven.
3fill in blank
hard

Fix the error in the test task configuration to use JUnit Platform.

JUnit
test {
    use[1]()
}
Drag options to blanks, or click blank then click option'
AJUnit4
BJUnitPlatform
CTestNG
DJUnit5
Attempts:
3 left
💡 Hint
Common Mistakes
Using useJUnit5() which does not exist.
Using useJUnit4() which runs only JUnit 4 tests.
4fill in blank
hard

Fill both blanks to add JUnit Jupiter Engine and enable test logging.

JUnit
dependencies {
    testRuntimeOnly '[1]'
}
test {
    testLogging {
        events [2]
    }
}
Drag options to blanks, or click blank then click option'
A"org.junit.jupiter:junit-jupiter-engine:5.9.3"
B["passed", "skipped", "failed"]
C"passed", "skipped", "failed"
D"org.junit.jupiter:junit-jupiter-api:5.9.3"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the API dependency instead of the engine for runtime.
Passing events as a list instead of separate strings.
5fill in blank
hard

Fill all three blanks to configure Gradle to use JUnit 5 with correct dependencies and test task.

JUnit
plugins {
    id '[1]'
}
dependencies {
    testImplementation '[2]'
    testRuntimeOnly '[3]'
}
test {
    useJUnitPlatform()
}
Drag options to blanks, or click blank then click option'
A"java"
B"org.junit.jupiter:junit-jupiter-api:5.9.3"
C"org.junit.jupiter:junit-jupiter-engine:5.9.3"
D"application"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong plugin id like application.
Mixing up API and engine dependencies.
Forgetting to configure useJUnitPlatform().