- Home
- Skills
- Kevintsengtw
- Dotnet Testing Agent Skills
- Dotnet Testing Code Coverage Analysis
dotnet-testing-code-coverage-analysis_skill
- C#
19
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill kevintsengtw/dotnet-testing-agent-skills --skill dotnet-testing-code-coverage-analysis- SKILL.md13.1 KB
Overview
This skill is a complete guide for .NET code coverage analysis focused on practical setup, reporting, and CI/CD integration. It covers Coverlet configuration, report generation with ReportGenerator, Fine Code Coverage and VS/VS Code workflows, and how to combine coverage with cyclomatic complexity to prioritize tests. The guidance emphasizes measurement use, not turning coverage into a KPI.
How this skill works
The skill inspects test project configuration, runsettings, and coverage collectors like coverlet.collector or dotnet-coverage, then runs tests to collect line, branch and method coverage. It generates output formats (lcov, cobertura, opencover, json) and can feed those into ReportGenerator or CI tasks for HTML reports and thresholds. It also analyzes cyclomatic complexity to recommend minimum test cases per method.
When to use it
- Setting up coverage collection for local development or CI/CD pipelines
- Configuring Coverlet, runsettings, or dotnet-coverage for .NET test projects
- Generating and interpreting coverage reports (line, branch, method)
- Visualizing coverage inside Visual Studio or VS Code (Fine Code Coverage or built-in tools)
- Prioritizing tests using cyclomatic complexity and coverage gaps
Best practices
- Use coverlet.collector or dotnet-coverage for CI-friendly, cross-platform collection
- Prefer meaningful assertions over chasing a numeric coverage target; coverage guides gaps, not quality
- Exclude generated code and trivial getters/setters via attributes or runsettings
- Start by securing core business logic, then expand to edge cases and exception flows
- Produce human-readable reports (ReportGenerator) and fail CI only on regressions or agreed thresholds
Example use cases
- Run dotnet test --collect:"XPlat Code Coverage" and publish HTML report via ReportGenerator in GitHub Actions
- Install Fine Code Coverage in Visual Studio to get inline green/yellow/red coloring during development
- Use runsettings to exclude third-party or generated code and set coverage thresholds for PR checks
- Combine cyclomatic complexity metrics to determine the minimum number of tests for a complex method
- Use VS Code with C# Dev Kit to run coverage and inspect lcov output when developing on macOS/Linux
FAQ
Check that coverlet.collector is installed, the runsettings are applied, tests actually run, and no broad exclusions hide results.
Which coverage metric matters most?
Line coverage is basic; branch coverage is more accurate for conditional logic. Use both plus method coverage to assess gaps.
Should coverage be a team KPI?
No. Coverage is a diagnostic tool. Using it as a KPI leads to shallow tests that lack assertions and value.