Challenge - 5 Problems
Coverage Threshold Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
JUnit Coverage Threshold Failure Output
Given the following JUnit test coverage configuration, what will be the test execution result if the coverage is 74% for branch coverage?
JUnit
jacoco {
toolVersion = "0.8.8"
reports {
xml.required.set(true)
html.required.set(true)
}
coverageVerification {
violationRules {
rule {
limit {
counter = 'BRANCH'
value = 'COVERED_RATIO'
minimum = '0.75'
}
}
}
}
}Attempts:
2 left
💡 Hint
Coverage verification rules enforce minimum coverage thresholds strictly.
✗ Incorrect
The coverageVerification rule requires branch coverage to be at least 75%. Since actual coverage is 74%, the build fails.
❓ assertion
intermediate1:30remaining
Assertion on Coverage Percentage in JUnit Test Report
Which assertion correctly verifies that the line coverage percentage is at least 80% in a JUnit test report parsed as a float variable named coverageLinePercent?
Attempts:
2 left
💡 Hint
Use an assertion that checks a condition is true for coverage threshold.
✗ Incorrect
assertTrue with condition coverageLinePercent >= 80.0 correctly asserts coverage meets or exceeds 80%.
🔧 Debug
advanced2:00remaining
Debugging Coverage Threshold Failure in JUnit
A JUnit test suite fails with a coverage threshold violation error, but the reported coverage is 85%. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the configured minimum coverage value in the build tool.
✗ Incorrect
If the threshold is set above 85%, coverage at 85% will fail the check.
❓ framework
advanced2:30remaining
Configuring Coverage Thresholds in JUnit with JaCoCo
Which snippet correctly configures JaCoCo in a Gradle build to fail the build if instruction coverage is below 90%?
Attempts:
2 left
💡 Hint
Minimum must be a string representing a decimal ratio between 0 and 1.
✗ Incorrect
JaCoCo expects minimum coverage as a string decimal like '0.9' for 90%.
🧠 Conceptual
expert3:00remaining
Impact of Coverage Thresholds on Continuous Integration
Which statement best describes the impact of strict coverage thresholds in a CI pipeline using JUnit and JaCoCo?
Attempts:
2 left
💡 Hint
Consider how coverage enforcement affects build success and developer actions.
✗ Incorrect
Strict coverage thresholds enforce quality but can cause builds to fail if coverage drops, prompting developers to fix tests or code.