How to Run Tests in the dotnet/skills Repository: A Complete Guide
To run tests in the dotnet/skills repository, use dotnet test with platform-specific flags that auto-detect between VSTest and Microsoft.Testing.Platform (MTP), handling SDK version differences and framework-specific filters automatically.
The dotnet/skills repository ships a collection of reusable .NET "skills" that agents use to execute, filter, and diagnose tests. The core logic resides in the dotnet-test plugin, specifically the run-tests skill defined in plugins/dotnet-test/skills/run-tests/SKILL.md, which automatically selects the correct command-line shape based on your test platform and SDK version.
Detect the Test Platform and SDK Version
Before executing tests, the skill inspects your repository's configuration to determine whether to use VSTest (the classic runner) or Microsoft.Testing.Platform (MTP) (the modern runner), and which .NET SDK version is in use.
Check Configuration Files
The detection logic examines several locations to identify the platform:
global.json: Contains"test": { "runner": "Microsoft.Testing.Platform" }for SDK 10+ MTP projects, or"sdk": { "version": "X.Y.Z" }to determine the SDK version.csprojorDirectory.Build.props: Look for<TestingPlatformDotnetTestSupport>trueto indicate MTP on SDK 8/9- Project references: Presence of
Microsoft.NET.Test.Sdkwithout MTP flags indicates classic VSTest
The detailed detection heuristics are documented in plugins/dotnet-test/skills/platform-detection/SKILL.md.
Choose the Correct dotnet test Invocation
The command structure varies significantly based on your platform and SDK version. According to the "Quick Reference" table in lines 66-70 of run-tests/SKILL.md:
VSTest (any SDK version):
dotnet test [<PATH>] [--filter <expr>] [--logger trx]
MTP on SDK 8 or 9:
dotnet test <PATH> -- <MTP_ARGS>
MTP on SDK 10+:
dotnet test --project <PATH> <MTP_ARGS>
Key Flag Differences
- TRX Reports: VSTest uses
--logger trx, while MTP requires--report-trx(from theMicrosoft.Testing.Extensions.TrxReportpackage) - Hang Detection: MTP uses
--blame-hang-timeout(requiresMicrosoft.Testing.Extensions.HangDump) - Code Coverage: MTP uses
--coverage(requiresMicrosoft.Testing.Extensions.CodeCoverage)
Run All Tests with Basic Commands
Execute the entire test suite using these patterns from the repository root:
# Auto-detect entry point (project or solution)
dotnet test
# Explicit project file (works for both platforms)
dotnet test --project src/MyProject.Tests/MyProject.Tests.csproj
# Explicit solution (required on SDK 10+)
dotnet test --solution src/MySolution.sln
The skill falls back to project-level discovery if no solution is present, as described in the Workflow section (lines 76-84) of run-tests/SKILL.md.
Filter and Run Subsets of Tests
Filter syntax varies by test framework and platform. The complete specification lives in plugins/dotnet-test/skills/filter-syntax/SKILL.md.
VSTest (universal syntax):
dotnet test --filter "TestCategory=Integration"
MTP with MSTest (SDK 8/9):
dotnet test --project Tests/Proj.csproj -- --filter "TestCategory=Integration"
MTP with xUnit v3 (SDK 10+):
dotnet test --project Tests/Proj.csproj --filter-trait "Category=Integration"
MTP with TUnit:
dotnet test --project Tests/Proj.csproj -- --treenode-filter "/*/*/*/*[Category=Integration]"
Remember that SDK 8/9 requires arguments after --, while SDK 10+ passes them directly (see lines 55-57 of run-tests/SKILL.md).
Collect Code Coverage and Reports
Generate coverage reports using the appropriate collector for your platform.
Using Coverlet with VSTest:
dotnet test --collect:"XPlat Code Coverage"
Using MTP's built-in collector (SDK 10+):
dotnet test --project tests/MyProject.Tests/MyProject.Tests.csproj \
--coverage --coverage-output-format cobertura \
--coverage-output ./TestResults
The required flags for coverage analysis are detailed in plugins/dotnet-test/skills/coverage-analysis/SKILL.md (lines 70-72).
Troubleshoot Common Pitfalls
| Symptom | Cause | Solution |
|---|---|---|
--report-trx not recognized |
Using MTP flag on VSTest project | Switch to --logger trx or add the MTP package |
--filter ignored on xUnit v3 |
Using VSTest syntax on MTP | Use --filter-trait or --filter-query |
| "No test is available" | Missing Microsoft.NET.Test.Sdk |
Add the package reference to your test project |
| "-- separator required" on SDK 10+ | Accidentally using -- on newer SDK |
Remove the separator and pass flags directly |
| "No test project found" | Path points to directory without .csproj |
Use --project <path> or --solution <path> |
These issues are catalogued in the "Common Pitfalls" table (lines 58-68) of run-tests/SKILL.md.
Summary
- dotnet/skills uses the
dotnet-testplugin to automatically detect between VSTest and Microsoft.Testing.Platform (MTP) based onglobal.jsonand.csprojsettings. - SDK version matters: SDK 8/9 requires
--before MTP arguments, while SDK 10+ does not. - Filter syntax varies: VSTest uses
--filter, while MTP xUnit v3 uses--filter-traitand TUnit uses--treenode-filter. - TRX reporting: Use
--logger trxfor VSTest and--report-trxfor MTP with the appropriate extension package. - Coverage: Install
Microsoft.Testing.Extensions.CodeCoveragefor MTP or use Coverlet collectors for VSTest.
Frequently Asked Questions
What is the difference between VSTest and Microsoft.Testing.Platform in dotnet/skills?
VSTest is the legacy test runner that works with any .NET SDK version and uses --logger trx for reports. Microsoft.Testing.Platform (MTP) is the modern, extensible runner introduced in newer SDKs that requires specific extension packages like Microsoft.Testing.Extensions.TrxReport for TRX output and uses different argument patterns depending on whether you are using SDK 8/9 (requires -- separator) or SDK 10+ (direct arguments).
Why do I need to use -- when running tests on SDK 8 or 9?
On SDK 8 and 9, the dotnet test command passes all arguments after -- directly to the underlying test runner when using MTP. This separator distinguishes between dotnet test options and runner-specific options. SDK 10+ removes this requirement, allowing you to pass MTP flags directly without the separator, as implemented in the command-line logic described in run-tests/SKILL.md (lines 55-57).
How do I filter tests by category in dotnet/skills?
The approach depends on your test framework and platform. For VSTest or MSTest, use --filter "TestCategory=Integration". For MTP with xUnit v3, use --filter-trait "Category=Integration" on SDK 10+, or -- --filter-trait on SDK 8/9. For TUnit, use the --treenode-filter syntax with the specific path pattern. Refer to plugins/dotnet-test/skills/filter-syntax/SKILL.md for the complete mapping of framework-specific filter expressions.
How do I generate TRX test reports in dotnet/skills?
For VSTest projects, add --logger trx to your command. For MTP projects, you must first install the Microsoft.Testing.Extensions.TrxReport NuGet package, then use --report-trx (after -- on SDK 8/9, or directly on SDK 10+). The skill automatically selects the correct flag based on platform detection, but manual runs require you to know which runner your project uses.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →