This document describes the enhanced code coverage reporting implemented in the Azure DevOps pipeline for smtp4dev.
The pipeline now generates more useful code coverage reports by:
- Namespace-level breakdown: Groups coverage by namespace to show which parts of the codebase have good/poor coverage
- Visual indicators: Uses color-coded badges (🟢🟡🔴) to quickly identify coverage levels
- Comprehensive details: Shows line, branch, and method coverage for each namespace
- GitHub integration: Posts enhanced reports as PR comments for easy visibility
The coverage report now includes:
- Overall coverage summary with color-coded status indicators
- Namespace breakdown table showing coverage metrics for each namespace
- Class counts per namespace to understand scope
- Direct links to detailed coverage reports in Azure DevOps
Coverage badges are color-coded based on these thresholds:
- 🟢 Green: ≥80% coverage (Good)
- 🟡 Yellow: 60-79% coverage (Moderate)
- 🔴 Red: <60% coverage (Needs improvement)
## 📊 Code Coverage Report
| Coverage Type | Percentage | Status |
|---------------|------------|--------|
| Line Coverage | 71.3% | 🟡 |
| Branch Coverage | 61.7% | 🟡 |
| Method Coverage | 69% | 🟡 |
### 📁 Coverage by Namespace
| Namespace | Line Coverage | Branch Coverage | Method Coverage | Classes |
|-----------|---------------|-----------------|-----------------|---------|
| `Rnwood.SmtpServer` | 74.5% 🟡 | 68.2% 🟡 | 69.5% 🟡 | 43 |
| `Rnwood.SmtpServer.Extensions` | 74.2% 🟡 | 25% 🔴 | 91.3% 🟢 | 6 |
| `Rnwood.SmtpServer.Extensions.Auth` | 57.5% 🔴 | 48.8% 🔴 | 57.5% 🔴 | 23 |
| `Rnwood.SmtpServer.Verbs` | 100% 🟢 | 100% 🟢 | 100% 🟢 | 4 |The enhancement is implemented in the ReportCoverage stage of azure-pipelines.yml:
- Coverage data parsing: Reads
Summary.jsongenerated by ReportGenerator - Namespace grouping: Extracts namespace information from class names
- Coverage calculation: Aggregates line/branch/method coverage per namespace
- GitHub API integration: Posts/updates PR comments with enhanced reports
The script handles various class naming patterns:
- Simple classes:
Namespace.ClassName - Nested classes:
Namespace.ClassName/NestedClass - Multi-level namespaces:
Namespace.SubNamespace.ClassName
The pipeline includes preparation for PR delta reporting:
# Future enhancement: Download base branch coverage for comparison
# To implement PR deltas:
# 1. Get base branch name: $(System.PullRequest.TargetBranch)
# 2. Download artifact from latest successful build on base branch
# 3. Compare current vs base coverage using enhanced script logic
# 4. Add delta columns to namespace table and overall summary- Better visibility: Developers can quickly identify which namespaces need testing attention
- Focused effort: Coverage gaps are clearly highlighted by namespace
- Progress tracking: Visual indicators make it easy to see improvement trends
- Actionable insights: Namespace-level detail helps prioritize testing efforts
The enhanced reporting is automatically enabled for all PRs when:
- The
GITHUB_TOKENenvironment variable is configured - Coverage data is successfully collected during test runs
- The
ReportCoveragestage executes for PR builds
No additional configuration is required - the enhancement works with the existing coverage collection infrastructure.