# How to Run Tests in the dotnet/skills Repository: A Complete Guide

> Learn to run tests in the dotnet/skills repository using dotnet test. Discover how to leverage platform-specific flags for automatic detection of VSTest and MTP, handling SDK versions and filters effortlessly.

- Repository: [.NET Platform/skills](https://github.com/dotnet/skills)
- Tags: how-to-guide
- Published: 2026-07-08

---

**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`](https://github.com/dotnet/skills/blob/main/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`](https://github.com/dotnet/skills/blob/main/global.json)**: Contains `"test": { "runner": "Microsoft.Testing.Platform" }` for SDK 10+ MTP projects, or `"sdk": { "version": "X.Y.Z" }` to determine the SDK version
- **`.csproj` or `Directory.Build.props`**: Look for `<TestingPlatformDotnetTestSupport>true` to indicate MTP on SDK 8/9
- **Project references**: Presence of `Microsoft.NET.Test.Sdk` without MTP flags indicates classic VSTest

The detailed detection heuristics are documented in [`plugins/dotnet-test/skills/platform-detection/SKILL.md`](https://github.com/dotnet/skills/blob/main/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`](https://github.com/dotnet/skills/blob/main/run-tests/SKILL.md):

**VSTest** (any SDK version):

```bash
dotnet test [<PATH>] [--filter <expr>] [--logger trx]

```

**MTP on SDK 8 or 9**:

```bash
dotnet test <PATH> -- <MTP_ARGS>

```

**MTP on SDK 10+**:

```bash
dotnet test --project <PATH> <MTP_ARGS>

```

### Key Flag Differences

- **TRX Reports**: VSTest uses `--logger trx`, while MTP requires `--report-trx` (from the `Microsoft.Testing.Extensions.TrxReport` package)
- **Hang Detection**: MTP uses `--blame-hang-timeout` (requires `Microsoft.Testing.Extensions.HangDump`)
- **Code Coverage**: MTP uses `--coverage` (requires `Microsoft.Testing.Extensions.CodeCoverage`)

## Run All Tests with Basic Commands

Execute the entire test suite using these patterns from the repository root:

```bash

# Auto-detect entry point (project or solution)

dotnet test

```

```bash

# Explicit project file (works for both platforms)

dotnet test --project src/MyProject.Tests/MyProject.Tests.csproj

```

```bash

# 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`](https://github.com/dotnet/skills/blob/main/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`](https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/filter-syntax/SKILL.md).

**VSTest** (universal syntax):

```bash
dotnet test --filter "TestCategory=Integration"

```

**MTP with MSTest** (SDK 8/9):

```bash
dotnet test --project Tests/Proj.csproj -- --filter "TestCategory=Integration"

```

**MTP with xUnit v3** (SDK 10+):

```bash
dotnet test --project Tests/Proj.csproj --filter-trait "Category=Integration"

```

**MTP with TUnit**:

```bash
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`](https://github.com/dotnet/skills/blob/main/run-tests/SKILL.md)).

## Collect Code Coverage and Reports

Generate coverage reports using the appropriate collector for your platform.

**Using Coverlet with VSTest**:

```bash
dotnet test --collect:"XPlat Code Coverage"

```

**Using MTP's built-in collector** (SDK 10+):

```bash
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`](https://github.com/dotnet/skills/blob/main/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`](https://github.com/dotnet/skills/blob/main/run-tests/SKILL.md).

## Summary

- **dotnet/skills** uses the `dotnet-test` plugin to automatically detect between VSTest and Microsoft.Testing.Platform (MTP) based on [`global.json`](https://github.com/dotnet/skills/blob/main/global.json) and `.csproj` settings.
- **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-trait` and TUnit uses `--treenode-filter`.
- **TRX reporting**: Use `--logger trx` for VSTest and `--report-trx` for MTP with the appropriate extension package.
- **Coverage**: Install `Microsoft.Testing.Extensions.CodeCoverage` for 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`](https://github.com/dotnet/skills/blob/main/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`](https://github.com/dotnet/skills/blob/main/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.