mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
3d59e44c7e
* Fix coverage-analysis activation for plateau diagnosis prompts coverage-analysis SKILL.md: - Trim verbose implementation details (provider detection, ReportGenerator) that consumed description budget without aiding skill activation - Add explicit USE FOR keywords: coverage stuck, coverage plateau, can't increase coverage, what's blocking coverage code-testing-agent SKILL.md: - Add 'diagnosing coverage plateaus or CRAP score computation (use coverage-analysis)' to DO NOT USE FOR boundary to prevent test-generation skill from intercepting diagnostic prompts * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Strengthen code-testing-agent activation; harden coverage-analysis isolated mode Address eval regressions reported on PR #647 (run 25813728646): 1. code-testing-agent: `Generate tests for ContosoUniversity ASP.NET Core MVC app` was NOT ACTIVATED in plugin mode (detectedSkills=[], skillEventCount=0, invokedAgents=[]). The model bypassed the skill system entirely. - SKILL.md description: restructure to use the proven `Use when user says ...` pattern with quoted trigger phrases (matching the run-tests skill that consistently activates), make the link to the code-testing-generator sub-agent explicit, and tighten DO NOT USE FOR clauses. - eval prompt (eval.yaml + eval.vally.yaml): make the request pipeline-shaped (`project-wide, multi-file test generation task`, `scaffold a new test project`) so the model recognizes it as multi-step work that benefits from the orchestrated pipeline. Explicitly request coverlet.collector + a Cobertura XML run so rubric criterion 1 (`high line coverage as reported by the Cobertura XML in TestResults/`) becomes achievable without overfitting. 2. code-testing-tester agent + code-testing-extensions/dotnet.md: open a scoped exception to the `skip coverage tools` rule. Default behavior stays the same, but when the user/harness explicitly asks for a Cobertura/XML coverage artifact, the agent may add coverlet.collector to the generated test csproj so the harness's coverage command produces output. The agent still does not run the coverage command itself. 3. coverage-analysis SKILL.md: add a `User-visible output is mandatory` guard at the top of the Workflow section. The latest eval showed isolated mode producing literally `(no output)` in 2 of 3 scenarios — the agent ran Compute-CrapScores.ps1 / Extract-MethodCoverage.ps1 / ReportGenerator in parallel, then the session ended without ever surfacing findings. The guard tells the agent to always return a partial summary instead of ending silent, and to deprioritize ReportGenerator HTML when budget is tight. (Plugin-mode quality is already strong: 4.3 / 4.3 / 5.0 — no regression risk there.) Aggregate dotnet-test plugin description size: 14,925 chars (limit 15,000). skill-validator check passes (22 skills, 11 agents, 1 plugin); markdownlint passes for all 4 modified files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Restore MSTest modernization exclusion in code-testing-agent description * Fix isolated-mode coverage-analysis: emit summary before optional ReportGenerator The previous workflow encouraged the agent to run `dotnet tool install` for ReportGenerator in parallel with the CRAP scoring scripts (Phase 2 "Steps 3 and 4 in parallel" + Phase 3 "Steps 5 and 6 in parallel"). In isolated mode that pattern reliably crashed the session with "Failed to persist session events: timeout while waiting for mutex to become available" right after the scripts returned valid data, so the agent never produced the user-facing summary. Restructure the workflow into 5 phases: - Phase 1 (Setup) - unchanged - Phase 2 (Test execution) - skip when Cobertura XML already exists - Phase 3 (Analysis) - run only the two PowerShell scripts, no RG - Phase 4 (User-facing summary) - MANDATORY, must be the next assistant response after Phase 3, before any RG work; also save coverage-analysis.md as a secondary follow-up - Phase 5 (ReportGenerator HTML/CSV) - strictly optional, post-summary, skipped by default for existing-Cobertura and plateau-diagnosis paths Also update references/output-format.md so the Reports section marks RG artifacts as "Not generated (optional - request HTML reports to enable)" when Phase 5 has not run, and update references/guidelines.md so the "show and open the markdown report" rule explicitly defers to the user-facing assistant response. Targets the isolated-mode regressions in PR #647 eval: - Project-wide coverage with existing Cobertura: 1.0/5 -> expected 3+ - Coverage plateau diagnosis: 1.0/5 -> expected 3+ - Run coverage from scratch: 2.3/5 -> expected steady or up Verified: skill-validator check --plugin ./plugins/dotnet-test passes; markdownlint-cli2 clean on all 3 modified files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR #647 review comments 1. Prerequisites: distinguish the from-scratch path (needs NuGet for the coverage-provider package install + optional internet for ReportGenerator) from the existing-Cobertura path (needs neither). 2. Add Step 2c "Discover or accept existing Cobertura XML" so the existing-data path actually has $coberturaFiles populated before Phase 3, instead of relying on Phase 2's discovery (which it skips). Also clarify Step 2's destructive Remove-Item only manages the skill-owned coverage-analysis/ subdirectory. 3. references/output-format.md: replace the unconditional "Reports saved to: <coverageDir>/reports/" line with one that always points at <coverageDir>/ (markdown summary + raw Cobertura) and only mentions reports/ if Phase 5 ran. 4. Have Compute-CrapScores.ps1 emit OVERALL_LINE_COVERAGE and OVERALL_BRANCH_COVERAGE from the Cobertura root attributes, and update Phase 4 to read those values directly from the script's output. The Phase 4 mandatory-summary rule no longer requires a separate XML parse before composing the response. Verified: skill-validator check --plugin ./plugins/dotnet-test passes; markdownlint-cli2 clean on all modified files; Compute-CrapScores.ps1 smoke-tested on a synthetic Cobertura XML (emits OVERALL_LINE_COVERAGE:75, OVERALL_BRANCH_COVERAGE:50 alongside HOTSPOTS). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Apply suggestion from @Evangelink * Address unresolved coverage-analysis and eval review comments * Refine follow-up review feedback from validation * Tighten coverage aggregation fallback notes and counters * Clarify pre-response save instruction wording --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
dotnet-test
Skills and agents for running, generating, analyzing, migrating, and improving .NET tests across all major frameworks (MSTest, xUnit, NUnit, TUnit) and platforms (VSTest, Microsoft.Testing.Platform).
When to use this plugin
- Run tests — execute
dotnet testwith automatic platform/framework detection and filter syntax - Generate tests — scaffold comprehensive unit tests for any language via a multi-agent pipeline
- Migrate tests — upgrade MSTest v1/v2 → v3 → v4, xUnit v2 → v3, or VSTest → Microsoft.Testing.Platform
- Audit test quality — detect anti-patterns, test smells, assertion gaps, and coverage risks
- Improve testability — find static dependencies, generate wrappers, and migrate call sites to injectable abstractions
- Measure coverage — collect code coverage, compute CRAP scores, and surface risk hotspots
Skills
Test execution
| Skill | Description |
|---|---|
| run-tests | Run .NET tests via dotnet test with platform/framework auto-detection and filter support |
| mtp-hot-reload | Rapid test-fix iteration using MTP hot reload (edit code → re-run without rebuilding) |
Test generation
| Skill | Description |
|---|---|
| code-testing-agent | Multi-agent pipeline (Research → Plan → Implement → Build → Test → Fix → Lint) that generates tests for any language |
| writing-mstest-tests | Best practices and modern APIs for writing MSTest 3.x/4.x tests |
Test migration
| Skill | Description |
|---|---|
| migrate-mstest-v1v2-to-v3 | Upgrade MSTest v1 (assembly refs) or v2 (NuGet 1.x–2.x) to v3 |
| migrate-mstest-v3-to-v4 | Upgrade MSTest v3 to v4 — handles all source and behavioral breaking changes |
| migrate-xunit-to-xunit-v3 | Upgrade xUnit.net v2 to v3 |
| migrate-vstest-to-mtp | Migrate from VSTest runner to Microsoft.Testing.Platform |
Test quality & analysis
| Skill | Description |
|---|---|
| test-anti-patterns | Quick pragmatic scan for ~15 common test quality issues with severity ranking |
| test-smell-detection | Deep formal audit using academic test smell taxonomy (19 smell types) |
| assertion-quality | Measure assertion variety and depth — find shallow tests that barely verify anything |
| test-gap-analysis | Pseudo-mutation analysis to find test blind spots that coverage numbers miss |
| test-tagging | Tag tests with standardized traits (smoke, regression, boundary, critical-path, etc.) |
Coverage & risk
| Skill | Description |
|---|---|
| coverage-analysis | Project-wide code coverage collection with CRAP score computation and risk hotspot reporting |
| crap-score | Calculate CRAP (Change Risk Anti-Patterns) scores for individual methods, classes, or files |
Testability improvement
| Skill | Description |
|---|---|
| detect-static-dependencies | Scan C# code for hard-to-test statics (DateTime.Now, File.*, HttpClient, etc.) |
| generate-testability-wrappers | Generate wrapper interfaces or guide adoption of built-in abstractions (TimeProvider, IFileSystem) |
| migrate-static-to-wrapper | Bulk-replace static call sites with injected wrapper calls and add constructor injection |
Reference data (loaded by other skills)
| Skill | Description |
|---|---|
| code-testing-extensions | Language-specific guidance files loaded by the code-testing pipeline |
| platform-detection | Detect VSTest vs MTP and identify the test framework from project files |
| filter-syntax | Test filter syntax reference for VSTest and MTP across all frameworks |
| dotnet-test-frameworks | Framework detection patterns, assertion APIs, skip annotations, and lifecycle methods |
Agents
User-facing agents
These are the entry-point agents you invoke directly:
| Agent | Purpose |
|---|---|
| code-testing-generator | Orchestrates the full test generation pipeline (research → plan → implement → build → test → fix → lint) |
| test-migration | Auto-detects framework/version and routes to the correct migration skill |
| test-quality-auditor | Runs multi-skill audit pipelines for comprehensive test suite assessment |
| testability-migration | End-to-end testability improvement: detect → generate wrappers → migrate call sites |
Internal subagents
These are pipeline stages invoked automatically by the agents above (user-invocable: false). You do not need to call them directly:
| Agent | Called by | Purpose |
|---|---|---|
| code-testing-researcher | code-testing-generator | Analyzes codebase structure, testing patterns, and testability |
| code-testing-planner | code-testing-generator | Creates phased test implementation plans from research findings |
| code-testing-implementer | code-testing-generator | Implements one phase from the plan, runs build-test-fix cycles |
| code-testing-builder | code-testing-implementer | Runs build/compile commands and reports results |
| code-testing-tester | code-testing-implementer | Runs test commands and reports pass/fail results |
| code-testing-fixer | code-testing-implementer | Fixes compilation errors in source or test files |
| code-testing-linter | code-testing-implementer | Runs code formatting and linting |
Prerequisites
- .NET SDK installed (
dotneton PATH) - A project with an existing test framework (MSTest, xUnit, NUnit, or TUnit) for execution and analysis skills