Testing Integration
Code Coverage Dashboard
Visualize and analyze code coverage metrics for your .NET tests with an interactive dashboard featuring real-time charts, risk analysis, and comprehensive coverage reports.
Overview
Section titled “Overview”The Code Coverage Dashboard provides a comprehensive view of your test coverage, helping you identify untested code, high-risk areas, and maintain quality standards across your .NET projects.
Features
Section titled “Features”Interactive Coverage Visualization
Section titled “Interactive Coverage Visualization”- Circular Progress Indicators: Real-time line and branch coverage percentages with visual gauges
- Package Coverage Chart: Bar chart showing coverage breakdown by project/package with customizable visibility
- Risk Hotspots Table: Identifies classes with high complexity and low coverage
- Detailed Coverage Table: Expandable hierarchical view of packages, classes, and methods
Coverage Metrics
Section titled “Coverage Metrics”The dashboard tracks multiple coverage metrics:
- Line Coverage: Percentage of code lines executed by tests
- Branch Coverage: Percentage of conditional branches tested
- Method Coverage: Number of methods with test coverage
- Complexity Analysis: Cyclomatic complexity and CRAP index for risk assessment
Accessing the Coverage Dashboard
Section titled “Accessing the Coverage Dashboard”Run Tests with Coverage
Section titled “Run Tests with Coverage”- Open the Test Explorer (Testing icon in Activity Bar)
- Click the “Run All Tests with Coverage” button
- Tests execute with coverage collection enabled
- Coverage Dashboard opens automatically with results
Alternative Methods
Section titled “Alternative Methods”- Command Palette:
Ctrl+Shift+P→ “C# Dev Tools: Show Coverage Dashboard” - Context Menu: Right-click test project → “Run Tests with Coverage”
- Status Bar: Click on coverage percentage indicator (when available)
Understanding Coverage Metrics
Section titled “Understanding Coverage Metrics”Line Coverage
Section titled “Line Coverage”Shows the percentage of executable code lines that were executed during test runs.
- Green Badge (≥ 80%): Good coverage
- Yellow Badge (50-79%): Medium coverage
- Red Badge (< 50%): Poor coverage
Example:
Lines Covered: 1,234 / 1,500 = 82.3%Branch Coverage
Section titled “Branch Coverage”Measures how many decision points (if statements, loops, etc.) have been tested.
- 100%: All branches tested (both true and false paths)
- 50%: Only one path tested per decision
- 0%: Decision point not tested
Example:
// Branch coverage tracks both paths:if (condition) { // True path // Code here} else { // False path // Code here}CRAP Index (Change Risk Anti-Patterns)
Section titled “CRAP Index (Change Risk Anti-Patterns)”Identifies risky code by combining complexity and coverage:
CRAP = complexity² × (1 - coverage)³ + complexityRisk Levels:
- Low (1-10): Safe to modify
- Medium (11-30): Review before changes
- High (31-60): High risk, needs tests
- Critical (> 60): Dangerous to modify without tests
Coverage Dashboard Sections
Section titled “Coverage Dashboard Sections”
1. Summary Cards
Section titled “1. Summary Cards”At the top of the dashboard, you’ll find three circular progress cards:
Line Coverage Card
Section titled “Line Coverage Card”- Visual progress circle
- Percentage display
- Covered/Total lines ratio
- Detailed statistics
Branch Coverage Card
Section titled “Branch Coverage Card”- Visual progress circle
- Percentage display
- Covered/Total branches ratio
- Detailed statistics
Method Coverage Card
Section titled “Method Coverage Card”- Visual progress circle
- Percentage display
- Methods with coverage
- Total method count
2. Coverage by Package Chart
Section titled “2. Coverage by Package Chart”Interactive bar chart showing coverage by project/package:
- Hover: View exact coverage percentages
- Legend: Shows which projects are displayed
- Project Visibility Controls: Checkboxes below chart to show/hide specific projects
- Color Coding: Projects colored by coverage level (green/yellow/red)
Using Visibility Controls:
- Locate checkboxes below the chart
- Uncheck projects you want to hide
- Chart updates immediately
- Re-check to show projects again
3. Risk Hotspots
Section titled “3. Risk Hotspots”Table highlighting high-risk classes that need attention:

| Column | Description |
|---|---|
| Class | Class name and package |
| Methods | Number of methods in class |
| Complexity | Total cyclomatic complexity |
| Line Coverage | Percentage with badge |
| Branch Coverage | Percentage with badge |
| CRAP Index | Risk score |
| Risk | Risk level badge |
| Actions | Create Test button |
Features:
- Pagination: Navigate through hotspots (5 per page)
- Click Row: Opens class in editor at first method
- Create Test: Opens test generation dialog for the class
- Sorting: Automatically sorted by CRAP index (highest risk first)
4. Coverage Details Table
Section titled “4. Coverage Details Table”Comprehensive hierarchical view of all coverage data:

Structure:
- Packages (Projects) - Top level
- Classes - Expandable
- Methods - Individual coverage
- Classes - Expandable
Features:
- Search/Filter: Filter by package or class name
- Expand/Collapse: “Expand all” and “Collapse all” buttons
- Click Navigation: Click any item to open in editor
- Detailed Metrics: Shows covered/uncovered/total lines
Column Details:
- Name
- Covered lines
- Uncovered lines
- Total lines
- Line coverage %
- Branch coverage %
Creating Tests from Coverage
Section titled “Creating Tests from Coverage”From Risk Hotspots
Section titled “From Risk Hotspots”When you identify a high-risk class:
- Locate the class in Risk Hotspots table
- Click the “Create Test” button (test tube icon)
- Test Generation dialog opens
- Configure test settings:
- Select test project
- Choose test framework (xUnit, NUnit, MSTest)
- Select assertion library
- Enable AI-powered generation
- Click “Generate Tests”
- Tests are created for the class
Recommended Workflow
Section titled “Recommended Workflow”- Review Hotspots: Start with Critical and High risk classes
- Create Tests: Use Create Test button for quick access
- Run Tests: Execute new tests to verify
- Re-run Coverage: Check improved metrics
- Iterate: Continue until risk is acceptable
Solution-Level Coverage
Section titled “Solution-Level Coverage”Optimized Test Execution
Section titled “Optimized Test Execution”The coverage system uses optimized solution-level test execution:
- Single Command: Runs
dotnet testonce for entire solution - Fast Execution: Eliminates per-project overhead
- Automatic Merging: Combines coverage from all projects
- Accurate Results: Proper line-by-line hit aggregation
Coverage Report Merging
Section titled “Coverage Report Merging”When multiple test projects exist:
- Each project generates its own coverage report (Cobertura XML)
- Extension automatically detects all reports
- Reports are merged using intelligent aggregation:
- Line hits are summed across projects
- Branch coverage is combined
- Coverage percentages recalculated
- Merged report displayed in dashboard
Excluding Code from Coverage
Section titled “Excluding Code from Coverage”Exclude specific code using attributes:
[ExcludeFromCodeCoverage]public class AutoGeneratedClass{ // This class is excluded from coverage}
[ExcludeFromCodeCoverage]public void HelperMethod(){ // This method is excluded}Interpreting Results
Section titled “Interpreting Results”Good Coverage Indicators
Section titled “Good Coverage Indicators”✓ Line coverage ≥ 80%: Solid foundation
✓ Branch coverage ≥ 70%: Edge cases tested
✓ CRAP index < 30: Low modification risk
✓ Few red hotspots: Risk is manageable
Warning Signs
Section titled “Warning Signs”⚠ Line coverage < 60%: Insufficient testing
⚠ Branch coverage < 50%: Missing edge cases
⚠ CRAP index > 60: Dangerous to modify
⚠ Many critical hotspots: High project risk
Priority Actions
Section titled “Priority Actions”- Address Critical Hotspots First: Highest CRAP index
- Test Complex Code: High complexity, low coverage
- Cover Branches: Improve decision point testing
- Maintain Coverage: Don’t let it decrease
Best Practices
Section titled “Best Practices”Effective Coverage Testing
Section titled “Effective Coverage Testing”- Run Coverage Regularly: After each feature or sprint
- Set Coverage Goals: Aim for 80%+ line coverage
- Focus on Risk: Prioritize high CRAP index classes
- Test Branches: Ensure all decision paths tested
- Exclude Generated Code: Keep metrics meaningful
Recommended Workflow
Section titled “Recommended Workflow”1. Run All Tests with Coverage ↓2. Review Coverage Dashboard ↓3. Identify Risk Hotspots ↓4. Create Tests for High-Risk Classes ↓5. Run Tests Again ↓6. Verify Improved Coverage ↓7. Commit ChangesIntegration with Other Features
Section titled “Integration with Other Features”Test Generation
Section titled “Test Generation”- Create tests from Risk Hotspots table
- AI-powered test creation for low-coverage classes
- See Test Generation
Test Explorer
Section titled “Test Explorer”- Run tests with coverage from Test Explorer
- View coverage status in test tree
- See Running and Debugging Tests
Solution Explorer
Section titled “Solution Explorer”- Right-click test projects → “Run Tests with Coverage”
- Access coverage from project context menu
- See Solution Explorer
Advanced Features
Section titled “Advanced Features”Inline Editor Decorations
Section titled “Inline Editor Decorations”Coverage indicators appear directly in your code editor:

Features:
- Covered Lines: Green background highlighting
- Uncovered Lines: Red background highlighting
- Toggle On/Off: Use command palette or coverage dashboard
- Real-time Updates: Automatically refresh after test runs
- Multi-file Support: Works across all C# files in solution
To toggle decorations:
- Open Command Palette (Ctrl+Shift+P)
- Search for “Toggle Test Coverage Decorations”
- Or use the toggle button in the coverage dashboard
Custom Coverage Thresholds
Section titled “Custom Coverage Thresholds”Edit coverage thresholds by modifying source:
- Good: ≥ 80% (green)
- Medium: 50-79% (yellow)
- Poor: < 50% (red)
Export Coverage Data
Section titled “Export Coverage Data”Coverage data stored in Cobertura XML format:
TestResults/ {guid}/ coverage.cobertura.xmlCan be used with:
- CI/CD pipelines
- Coverage reporting tools
- Code quality platforms
- Historical analysis tools
Coverage Trends
Section titled “Coverage Trends”Track coverage over time:
- Save coverage reports after each run
- Compare reports to see improvements
- Use external tools for trend visualization
- Set up alerts for coverage drops
Related Documentation
Section titled “Related Documentation”- Running and Debugging Tests - Test execution basics
- Test Generation - Create tests with AI
- SpecFlow Support - BDD testing coverage
- Playwright Integration - E2E test coverage