Code Coverage Improvement Plan — cli/azd
Background
Over the past month, we've executed a multi-phase effort to improve test coverage in the azure-dev CLI. This issue tracks the overall progress, documents what's been accomplished, and outlines the remaining work.
Coverage Journey (March–April 2026)
| Phase |
PR |
Key Changes |
Coverage Impact |
| Foundation |
#7188 |
Enforce minimum coverage threshold in CI pipeline |
CI gate established |
| Wave 1 |
#7297 |
Unit test coverage across core packages |
Initial lift |
| Wave 2 |
#7369 |
Coverage wave 2 + test timing infrastructure |
~48% → 52% |
| Phase 1-2 |
#7424 |
Coverage tooling, mage targets, developer workflow, Phase 1-2 tests |
52% → 55% |
| Phase 3 |
#7496 |
cmd, project, azapi, pipeline, grpcserver coverage |
55% → 58% (current CI gate) |
Tooling introduced:
mage coverage:unit / :full / :hybrid / :ci / :html / :check — developer coverage workflow
Get-LocalCoverageReport.ps1 / Get-CICoverageReport.ps1 — coverage report scripts
Test-TestTiming.ps1 — test timing analysis to catch slow tests
Current State (April 2026)
Overall: 876 source files, 627 test files (0.72 ratio), CI threshold at 58%.
Latest Coverage Improvements (In Progress — Not Yet in PR)
| Package |
Before |
After |
Delta |
pkg/ioc |
36.2% |
95.0% |
+58.8 |
internal/cmd/add |
16.1% |
26.7% |
+10.6 |
pkg/extensions |
75.1% |
79.3% |
+4.2 |
pkg/exec |
69.5% |
72.9% |
+3.4 |
pkg/auth |
80.0% |
80.2% |
+0.2 |
9 new test files covering: sanitizer_test.go, runresult_test.go, remote_credential_test.go, credential_providers_test.go, command_resolver_test.go, extension_test.go, runner_test.go, container_coverage_test.go (ioc), add_coverage_test.go
Remaining Gaps — Prioritized
🔴 Tier 1: Critical (< 20% coverage)
| Package |
Coverage |
Priority |
Notes |
pkg/devcentersdk |
4.3% |
HIGH |
SDK — needs httptest/recording tests |
pkg/azdo |
8.4% |
HIGH |
Azure DevOps pipeline integration |
pkg/azureutil |
10.0% |
MEDIUM |
Location/principal utils (small surface) |
pkg/ux/internal |
10.6% |
HIGH |
Core UX input framework |
pkg/azsdk/storage |
14.5% |
MEDIUM |
Azure Storage SDK wrapper |
pkg/apphost |
18.7% |
HIGH |
.NET Aspire app host support |
🟡 Tier 2: Below Threshold (20-50%)
| Package |
Coverage |
Priority |
Notes |
pkg/azdext |
24.9% |
MEDIUM |
Extension SDK |
pkg/azsdk |
25.4% |
MEDIUM |
Azure SDK core wrappers |
pkg/tools/dotnet |
26.6% |
MEDIUM |
.NET tool integration |
internal/cmd/add |
26.7% |
MEDIUM |
azd add command (improved from 16.1%) |
pkg/prompt |
31.3% |
MEDIUM |
Prompt framework |
pkg/github |
35.7% |
MEDIUM |
GitHub integration |
pkg/containerregistry |
37.1% |
MEDIUM |
ACR wrapper |
pkg/environment/azdcontext |
37.2% |
HIGH |
Core environment context |
pkg/ai |
37.8% |
MEDIUM |
AI integration |
pkg/output |
41.4% |
LOW |
Output formatting |
pkg/keyvault |
41.5% |
MEDIUM |
Key Vault integration |
pkg/tools/bicep |
44.1% |
MEDIUM |
Bicep tool |
internal/agent/copilot |
45.3% |
LOW |
Copilot agent |
internal/vsrpc |
46.4% |
LOW |
VS RPC service |
pkg/infra/provisioning/bicep |
49.7% |
MEDIUM |
Bicep provisioning |
🟢 Tier 3: Modernization and Quality
Proposed Next Phases
Phase 4: Close Critical Gaps (target: 62% overall)
- Add httptest-based tests for
pkg/devcentersdk (4.3% → 40%+)
- Add tests for
pkg/azdo (8.4% → 40%+)
- Improve
pkg/ux/internal (10.6% → 50%+)
- Add tests for
pkg/apphost (18.7% → 40%+)
- Improve
pkg/environment/azdcontext (37.2% → 60%+)
Phase 5: Raise the Floor (target: 65% overall)
- Get all Tier 2 packages above 50%
- Focus on:
azdext, azsdk, prompt, github, containerregistry, ai
- Raise CI coverage gate from 58% → 65%
Phase 6: Modernization
- Bulk migrate
context.Background() → t.Context() across 241 test files
- Replace
time.Sleep with proper async waiting patterns
- Audit and fix or remove
t.Skip calls
Test Quality Strengths (preserve these)
- Table-driven tests: 287 files, 654 occurrences
- Subtests: 415 files, 2,499
t.Run calls
- Error path testing: 306 files with
require.Error
- Parallel tests: 153 files, 2,318
t.Parallel() calls
- Modern Go 1.26: 98 files already using
t.Context()
- Rich mock infrastructure:
test/mocks/, test/recording/
How to Measure Progress
# Local unit coverage (quick)
mage coverage:unit
# Full local coverage (unit + integration)
mage coverage:full
# Hybrid (local unit + CI integration)
mage coverage:hybrid
# Check threshold
COVERAGE_MIN=65 mage coverage:check
# HTML report
mage coverage:html
Code Coverage Improvement Plan —
cli/azdBackground
Over the past month, we've executed a multi-phase effort to improve test coverage in the azure-dev CLI. This issue tracks the overall progress, documents what's been accomplished, and outlines the remaining work.
Coverage Journey (March–April 2026)
Tooling introduced:
mage coverage:unit/:full/:hybrid/:ci/:html/:check— developer coverage workflowGet-LocalCoverageReport.ps1/Get-CICoverageReport.ps1— coverage report scriptsTest-TestTiming.ps1— test timing analysis to catch slow testsCurrent State (April 2026)
Overall: 876 source files, 627 test files (0.72 ratio), CI threshold at 58%.
Latest Coverage Improvements (In Progress — Not Yet in PR)
pkg/iocinternal/cmd/addpkg/extensionspkg/execpkg/auth9 new test files covering:
sanitizer_test.go,runresult_test.go,remote_credential_test.go,credential_providers_test.go,command_resolver_test.go,extension_test.go,runner_test.go,container_coverage_test.go(ioc),add_coverage_test.goRemaining Gaps — Prioritized
🔴 Tier 1: Critical (< 20% coverage)
pkg/devcentersdkpkg/azdopkg/azureutilpkg/ux/internalpkg/azsdk/storagepkg/apphost🟡 Tier 2: Below Threshold (20-50%)
pkg/azdextpkg/azsdkpkg/tools/dotnetinternal/cmd/addpkg/promptpkg/githubpkg/containerregistrypkg/environment/azdcontextpkg/aipkg/outputpkg/keyvaultpkg/tools/bicepinternal/agent/copilotinternal/vsrpcpkg/infra/provisioning/bicep🟢 Tier 3: Modernization and Quality
context.Background()→t.Context()— 241 test files still use the old pattern (Go 1.26+ hast.Context())time.Sleepin tests — 12 files usetime.Sleep, replace with polling/event-based waitingt.Skip— 26 files with 58 skip calls that may hide coverage gapsProposed Next Phases
Phase 4: Close Critical Gaps (target: 62% overall)
pkg/devcentersdk(4.3% → 40%+)pkg/azdo(8.4% → 40%+)pkg/ux/internal(10.6% → 50%+)pkg/apphost(18.7% → 40%+)pkg/environment/azdcontext(37.2% → 60%+)Phase 5: Raise the Floor (target: 65% overall)
azdext,azsdk,prompt,github,containerregistry,aiPhase 6: Modernization
context.Background()→t.Context()across 241 test filestime.Sleepwith proper async waiting patternst.SkipcallsTest Quality Strengths (preserve these)
t.Runcallsrequire.Errort.Parallel()callst.Context()test/mocks/,test/recording/How to Measure Progress