Use the open-source free `coverlet` toolchain for .NET code coverage.
MSTest
Write, run, or repair .NET tests that use MSTest. Use when a repo uses `MSTest.Sdk`, `MSTest`, `[TestClass]`, `[TestMethod]`, `DataRow`, or Microsoft.Testing.Platform-based MSTest execution.
Trigger On
- the repo uses MSTest
- you need to add, run, debug, or repair MSTest tests
- the repo is moving between VSTest and Microsoft.Testing.Platform
Workflow
- Detect the MSTest project style first:
- MSTest.Sdk project SDK - MSTest meta-package - legacy package set with explicit Microsoft.NET.Test.Sdk
- Read the repo's real
testcommand fromAGENTS.md. If the repo has no explicit command yet, start withdotnet test PROJECT_OR_SOLUTION. - Keep the runner model consistent:
- MSTest.Sdk defaults to the MSTest runner on Microsoft.Testing.Platform - VSTest is opt-in with UseVSTest=true or legacy package choices - do not pass VSTest-only switches or assume legacy .runsettings behavior on Microsoft.Testing.Platform jobs
- Prefer
[DataRow]orDynamicDatafor stable data-driven coverage. Keep test lifecycle hooks minimal and deterministic. - Keep MSTest analyzers enabled and fix findings instead of muting them casually.
- Align coverage/reporting packages with the active runner.
Deliver
- MSTest tests that match the repo's runner model
- commands that work in local and CI runs
- explicit guidance for VSTest versus Microsoft.Testing.Platform usage
Validate
- the runner model is documented and consistent
- test commands match that runner
- data-driven tests stay deterministic
- analyzer, coverage, and reporting packages align with the chosen runner
Load References
references/mstest.mdreferences/patterns.mdreferences/anti-patterns.md
Related skills
coverlet.collectorcoverlet.msbuild
Write, run, or repair .NET tests that use NUnit.
NUnitNUnit3TestAdapter
Automated, project-wide code coverage and CRAP (Change Risk Anti-Patterns) score analysis for .NET projects with existing unit tests.
coverlet.collectorcoverlet.msbuild