Introduction
In the previous blog, From Guesswork to Insights: Building Code Coverage Visibility, we explored how establishing a coverage baseline helped transform code coverage from assumptions into measurable insights.
While visibility helps teams understand testing effectiveness, it does not prevent coverage from declining as new code is introduced. To maintain quality standards, coverage validation must become part of the development process.
This blog describes how SonarQube Quality Gates were integrated into a Business Automation Workflow (BAW) project to provide automated feedback and enforce coverage expectations during Pull Request reviews
Why Visibility Alone Was Not Enough
After coverage metrics became available, teams gained insight into testing gaps and overall coverage levels. However, a key question remained:
How do we ensure new code continues to meet quality expectations?
Without automated validation:
- Coverage can gradually decline.
- Quality issues may be detected late.
- Reviewers must manually assess coverage.
- Standards may vary across teams.
To address these challenges, the focus shifted from measuring quality to governing it.
How Do We Move from Measuring Quality to Enforcing It?
Coverage Visibility and Quality Governance

The quality improvement initiative was built around two capabilities:
Coverage Visibility
Provides measurable insight into testing effectiveness and identifies coverage gaps.
Quality Governance
Applies automated quality standards to new code changes through SonarQube Quality Gates.
Together, these capabilities help drive continuous improvement.
How Can Coverage Validation Be Integrated into Pull Request Reviews?
To provide feedback earlier in the development lifecycle, coverage validation was integrated directly into Pull Request reviews.
Pull Request Coverage Validation Workflow

The automated workflow includes:
- Pull Request creation
- Build and test execution
- JaCoCo coverage generation
- SonarQube analysis
- Quality Gate evaluation
- Pull Request feedback
This allows developers and reviewers to see coverage results before code is merged
How Is Coverage Validation Integrated into Pull Requests?
To make quality validation part of the normal development process, the workflow was integrated into the existing Pull Request lifecycle.
Business Automation Workflow Pull Request Validation Process

The workflow consists of three stages:
Development
Developers implement changes and create Pull Requests.
Validation
Builds, tests, coverage generation, and SonarQube analysis run automatically.
Review
Reviewers assess code changes, coverage metrics, Quality Gate status, and SonarQube findings.
Quality feedback becomes part of the normal development process rather than a separate activity.
Quality Gate Enforcement in Action
Once the workflow was operational, coverage validation became an automated part of Pull Request review.
SonarQube Pull Request Analysis

In the example shown above:
- Coverage measured: 37.5%
- Required coverage threshold: 80%
- Quality Gate Status: Failed
At first glance, the coverage percentage appears low. However, the key outcome was not the percentage itself.
The objective was validating that:
✅ Coverage data was successfully generated
✅ Coverage reports were imported into SonarQube
✅ Pull Request analysis executed automatically
✅ Quality Gates evaluated defined thresholds
✅ Results were surfaced directly to developers and reviewers
The failed Quality Gate demonstrated that the governance mechanism was functioning as intended by identifying under-tested changes before they could be merged.
Why Quality Gates Matter
Quality Gates provide several important benefits:
- Early Feedback before code reaches the main branch.
- Consistent Standards across all Pull Requests.
- Reduced Quality Regression through automated thresholds.
- Data-Driven Decisions based on measurable quality metrics.
These benefits help establish a more predictable and sustainable approach to software quality.
Key Learnings
- Visibility is the foundation, but governance is required for improvement.
- New code coverage is an effective starting point for quality improvements.
- Automation increases adoption by delivering feedback within existing workflows.
- Quality Gates complement code reviews by enforcing objective standards
What's Next?
Future enhancements may include:
- Enhanced Quality Gate policies
- Branch-level analysis
- Coverage trend reporting
- Additional quality metrics
- Broader adoption across Business Automation components
These improvements can further strengthen quality governance throughout the software delivery lifecycle.
Conclusion
Visibility was an important first step in understanding code coverage, but long-term quality improvement requires enforcement.
By integrating SonarQube Quality Gates into the Pull Request workflow, the BAW project transformed coverage from a reporting metric into an automated quality control mechanism. The result is earlier feedback, more consistent standards, and greater confidence in code quality before changes are merged.