Challenge - 5 Problems
Code Coverage Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkins Pipeline: Code Coverage Report Generation
Given this Jenkins pipeline snippet, what will be the output after running the
jacoco step?Jenkins
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building project...'
}
}
stage('Test') {
steps {
echo 'Running tests...'
}
}
stage('Code Coverage') {
steps {
jacoco execPattern: '**/target/*.exec', classPattern: '**/classes', sourcePattern: '**/src/main/java'
}
}
}
}Attempts:
2 left
💡 Hint
The
jacoco step in Jenkins pipelines is used to collect and publish code coverage reports.✗ Incorrect
The
jacoco step collects coverage data from the specified exec files and generates a report Jenkins can display. It requires the JaCoCo plugin installed.❓ Troubleshoot
intermediate2:00remaining
Troubleshooting Missing Coverage Data in Jenkins
A Jenkins job runs tests and uses JaCoCo for coverage, but the coverage report shows 0% coverage. What is the most likely cause?
Attempts:
2 left
💡 Hint
Coverage data depends on tests running with the coverage agent active.
✗ Incorrect
If tests run without the JaCoCo agent, no coverage data is collected, resulting in 0% coverage report.
❓ Configuration
advanced2:00remaining
Configuring Jenkins to Fail Build on Low Coverage
Which Jenkins pipeline snippet correctly fails the build if code coverage is below 80% using JaCoCo plugin?
Attempts:
2 left
💡 Hint
Check the official JaCoCo plugin documentation for correct parameter names and types.
✗ Incorrect
The
changeBuildStatus parameter set to true enables build failure on coverage below thresholds. The threshold values are strings without % sign.🔀 Workflow
advanced2:00remaining
Best Workflow to Collect Coverage from Multiple Modules
You have a multi-module Maven project. How should you configure Jenkins to collect JaCoCo coverage reports from all modules correctly?
Attempts:
2 left
💡 Hint
Maven multi-module builds generate coverage files in each module's target directory.
✗ Incorrect
Running
mvn clean verify at root runs tests in all modules. Using a wildcard execPattern collects all coverage files for combined report.✅ Best Practice
expert3:00remaining
Ensuring Accurate Coverage Reports in Jenkins Pipelines
Which practice ensures the most accurate and reliable code coverage reports in Jenkins pipelines using JaCoCo?
Attempts:
2 left
💡 Hint
Coverage data must be collected during test execution and preserved for reporting.
✗ Incorrect
Enabling JaCoCo agent during tests collects coverage data. Archiving exec files ensures data is available for report generation after tests.