0
0
JUnittesting~10 mins

JaCoCo setup and configuration 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 JaCoCo plugin in a Gradle build script.

JUnit
plugins {
    id '[1]'
}
Drag options to blanks, or click blank then click option'
Amaven
Bjava
Capplication
Djacoco
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'java' instead of 'jacoco' as plugin id.
Forgetting to add the plugin block.
2fill in blank
medium

Complete the code to set the JaCoCo tool version in Gradle.

JUnit
jacoco {
    toolVersion = '[1]'
}
Drag options to blanks, or click blank then click option'
A0.8.7
B1.0.0
C0.7.5
D2.0.1
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid or non-existent version number.
Omitting the toolVersion setting.
3fill in blank
hard

Fix the error in the test task configuration to generate JaCoCo reports.

JUnit
tasks.test {
    useJUnitPlatform()
    finalizedBy('[1]')
}
Drag options to blanks, or click blank then click option'
AgenerateReport
BtestReport
CjacocoTestReport
DcoverageReport
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent task name in finalizedBy.
Forgetting to link the report generation task.
4fill in blank
hard

Fill both blanks to configure the JaCoCo report formats in Gradle.

JUnit
jacocoTestReport {
    reports {
        xml.required = [1]
        html.required = [2]
    }
}
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cnull
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using false disables the report format.
Using null or 0 causes errors.
5fill in blank
hard

Fill all three blanks to exclude generated classes from JaCoCo coverage.

JUnit
jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect { file ->
            fileTree(dir: file, exclude: [[1], [2], [3]])
        }))
    }
}
Drag options to blanks, or click blank then click option'
A'**/R.class'
B'**/BuildConfig.class'
C'**/Manifest.class'
D'**/Main.class'
Attempts:
3 left
💡 Hint
Common Mistakes
Including main classes in the exclude list.
Using incorrect patterns for exclusion.