Loading...
Loading...
Reference data for test filter syntax across all platform and framework combinations: VSTest --filter expressions, MTP filters for MSTest/NUnit/xUnit v3/TUnit, and VSTest-to-MTP filter translation. DO NOT USE directly — loaded by run-tests, mtp-hot-reload, and migrate-vstest-to-mtp when they need filter syntax.
npx skill4agent add dotnet/skills filter-syntaxdotnet test --filter <EXPRESSION><Property><Operator><Value>[|&<Expression>]| Operator | Meaning |
|---|---|
| Exact match |
| Not exact match |
| Contains |
| Does not contain |
|&(A|B)&C| Framework | Properties |
|---|---|
| MSTest | |
| xUnit | |
| NUnit | |
FullyQualifiedName~<value># Run tests whose name contains "LoginTest"
dotnet test --filter "Name~LoginTest"
# Run a specific test class
dotnet test --filter "ClassName=MyNamespace.MyTestClass"
# Run tests in a category
dotnet test --filter "TestCategory=Integration"
# Exclude a category
dotnet test --filter "TestCategory!=Slow"
# Combine: class AND category
dotnet test --filter "ClassName=MyNamespace.MyTestClass&TestCategory=Unit"
# Either of two classes
dotnet test --filter "ClassName=MyNamespace.ClassA|ClassName=MyNamespace.ClassB"--filter# .NET SDK 8/9 (after --)
dotnet test -- --filter "Name~LoginTest"
# .NET SDK 10+ (direct)
dotnet test --filter "Name~LoginTest"--filter| Flag | Description |
|---|---|
| Run all tests in a given class |
| Exclude all tests in a given class |
| Run a specific test method |
| Exclude a specific test method |
| Run all tests in a namespace |
| Exclude all tests in a namespace |
| Run tests with a matching trait |
| Exclude tests with a matching trait |
--filter-class Foo Bar# .NET SDK 8/9
dotnet test -- --filter-class "MyNamespace.LoginTests"
# .NET SDK 10+
dotnet test --filter-class "MyNamespace.LoginTests"
# Combine: namespace + trait
dotnet test --filter-namespace "MyApp.Tests.Integration" --filter-trait "Category=Smoke"--filter-query/<assemblyFilter>/<namespaceFilter>/<classFilter>/<methodFilter>[traitName=traitValue]*# xUnit.net v3 MTP — using query language (assembly/namespace/class/method[trait])
dotnet test -- --filter-query "/*/*/*IntegrationTests*/*[Category=Smoke]"--treenode-filter--treenode-filter "/<Assembly>/<Namespace>/<ClassName>/<TestName>"*| Operator | Meaning |
|---|---|
| Wildcard match |
| Exact property match (e.g., |
| Exclude property value |
| AND (combine conditions) |
| OR (within a segment, requires parentheses) |
# All tests in a class
dotnet run --treenode-filter "/*/*/LoginTests/*"
# A specific test
dotnet run --treenode-filter "/*/*/*/AcceptCookiesTest"
# By namespace prefix (wildcard)
dotnet run --treenode-filter "/*/MyProject.Tests.Api*/*/*"
# By custom property
dotnet run --treenode-filter "/*/*/*/*[Category=Smoke]"
# Exclude by property
dotnet run --treenode-filter "/*/*/*/*[Category!=Slow]"
# OR across classes
dotnet run --treenode-filter "/*/*/(LoginTests)|(SignupTests)/*"
# Combined: namespace + property
dotnet run --treenode-filter "/*/MyProject.Tests.Integration/*/*/*[Priority=Critical]"YTest.MTP.XUnit2--filter--filterVSTest | xUnit.net v3 MTP equivalent | Notes |
|---|---|---|
| | Wildcards required for substring match |
| | Exact match on fully qualified method |
| | Wildcards for substring match |
| | Filter by trait name/value pair |
| Complex expressions | | Uses xUnit.net query filter language (see above) |