0
0
JUnittesting~10 mins

Gradle test task 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 apply the Java plugin in Gradle.

JUnit
plugins {
    id '[1]'
}
Drag options to blanks, or click blank then click option'
Awar
Bapplication
Cmaven
Djava
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'application' plugin which is for runnable Java apps, not just testing.
Using 'maven' which is unrelated to Gradle plugins.
Using 'war' which is for web archives.
2fill in blank
medium

Complete the code to configure the test task to use JUnit Platform.

JUnit
test {
    use[1]()
}
Drag options to blanks, or click blank then click option'
ASpock
BJUnitPlatform
CTestNG
DJUnit4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'useJUnit4()' which is for older JUnit versions.
Using 'useTestNG()' which is for TestNG framework.
Using 'useSpock()' which is for Spock framework.
3fill in blank
hard

Fix the error in the test dependencies block to include JUnit Jupiter API.

JUnit
dependencies {
    testImplementation '[1]'
}
Drag options to blanks, or click blank then click option'
Aorg.junit.jupiter:junit-jupiter-api:5.9.3
Bjunit:junit:4.13.2
Corg.testng:testng:7.7.0
Dspock:spock-core:2.3-groovy-4.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using JUnit 4 dependency which is outdated for JUnit 5 tests.
Using TestNG or Spock dependencies which are different frameworks.
4fill in blank
hard

Fill both blanks to configure test logging to show passed and failed tests.

JUnit
test {
    testLogging {
        events [1]
        exceptionFormat [2]
    }
}
Drag options to blanks, or click blank then click option'
A['passed', 'failed']
B'full'
C'short'
D['skipped', 'standard']
Attempts:
3 left
💡 Hint
Common Mistakes
Using string instead of list for events.
Using 'short' exception format which shows less detail.
5fill in blank
hard

Fill all three blanks to create a custom test task named 'integrationTest' that runs after 'test'.

JUnit
task integrationTest(type: Test) {
    description = '[1]'
    group = '[2]'
    mustRunAfter [3]
}
Drag options to blanks, or click blank then click option'
ARuns integration tests
Bverification
Ctest
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong group name like 'build'.
Setting mustRunAfter to a task that does not exist.
Not providing a meaningful description.