
Test Filter Syntax Reference
FreeA comprehensive guide to test filter syntax for .NET.
Free · Opens the source repo
What Test Filter Syntax Reference does
The Test Filter Syntax Reference skill provides essential information on how to utilize filter syntax across various .NET testing frameworks, including VSTest, MSTest, NUnit, and xUnit. This skill is designed for developers who need to run specific tests or groups of tests based on defined criteria, making it a valuable resource for anyone involved in .NET application development and testing.
With this skill, users can quickly reference the appropriate filter expressions for their testing needs. It covers the syntax for VSTest filters, which are applicable to MSTest, NUnit, and xUnit v2, as well as the differences in syntax for xUnit v3 and TUnit. The skill includes detailed explanations of operators, combinators, and properties that can be used in filter expressions, along with practical examples to illustrate their usage.
The skill is particularly useful for developers working in CI/CD environments, as it allows them to efficiently run tests based on specific criteria, such as test names, categories, or properties. By understanding how to construct and apply these filters, developers can streamline their testing processes and ensure that only relevant tests are executed, saving time and resources.
However, this skill is not intended for direct use; it is meant to be loaded by other tools like run-tests and mtp-hot-reload. Therefore, it is essential for users to integrate it into their existing workflows to fully leverage its capabilities.
When to use it
Use this skill when you need to reference or construct test filter expressions for .NET testing frameworks.
When not to use it
This skill is not suitable for users looking for a direct testing tool; it serves as a reference for syntax only.
What you can build with it
Running Specific Tests
Use the filter syntax to run tests that match specific criteria, such as names or categories.
Migrating Test Frameworks
Reference the syntax differences when migrating from VSTest to MTP for seamless transitions.
Optimizing CI/CD Pipelines
Incorporate filter expressions into CI/CD workflows to run only relevant tests, improving efficiency.
How to install Test Filter Syntax Reference
View source1. Install with the skills CLI
npx skills add dotnet/skills/filter-syntax --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by dotnetTest Filter Syntax Reference
Filter syntax depends on the platform and test framework.
VSTest filters (MSTest, xUnit v2, NUnit on VSTest)
dotnet test --filter <EXPRESSION>
Expression syntax: <Property><Operator><Value>[|&<Expression>]
Operators:
| Operator | Meaning |
|---|---|
= | Exact match |
!= | Not exact match |
~ | Contains |
!~ | Does not contain |
Combinators: | (OR), & (AND). Parentheses for grouping: (A|B)&C
Supported properties by framework:
| Framework | Properties |
|---|---|
| MSTest | FullyQualifiedName, Name, ClassName, Priority, TestCategory |
| xUnit | FullyQualifiedName, DisplayName, Traits |
| NUnit | FullyQualifiedName, Name, Priority, TestCategory |
An expression without an operator is treated as FullyQualifiedName~<value>.
Examples (VSTest):
# 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"
MTP filters — MSTest and NUnit
MSTest and NUnit on MTP use the same --filter syntax as VSTest (same properties, operators, and combinators). The only difference is how the flag is passed:
# .NET SDK 8/9 (after --)
dotnet test -- --filter "Name~LoginTest"
# .NET SDK 10+ (direct)
dotnet test --filter "Name~LoginTest"
MTP filters — xUnit (v3)
xUnit v3 on MTP uses framework-specific filter flags instead of the generic --filter expression:
| Flag | Description |
|---|---|
--filter-class "name" | Run all tests in a given class |
--filter-not-class "name" | Exclude all tests in a given class |
--filter-method "name" | Run a specific test method |
--filter-not-method "name" | Exclude a specific test method |
--filter-namespace "name" | Run all tests in a namespace |
--filter-not-namespace "name" | Exclude all tests in a namespace |
--filter-trait "name=value" | Run tests with a matching trait |
--filter-not-trait "name=value" | Exclude tests with a matching trait |
Multiple values can be specified with a single flag: --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"
xUnit v3 query filter language
For complex expressions, use --filter-query with a path-segment syntax:
/<assemblyFilter>/<namespaceFilter>/<classFilter>/<methodFilter>[traitName=traitValue]
Each segment matches against: assembly name, namespace, class name, method name. Use * for "match all" in any segment. Documentation: https://xunit.net/docs/query-filter-language
# xUnit.net v3 MTP — using query language (assembly/namespace/class/method[trait])
dotnet test -- --filter-query "/*/*/*IntegrationTests*/*[Category=Smoke]"
MTP filters — TUnit
TUnit uses --treenode-filter with a path-based syntax:
--treenode-filter "/<Assembly>/<Namespace>/<ClassName>/<TestName>"
Wildcards (*) are supported in any segment. Filter operators can be appended to test names for property-based filtering.
| Operator | Meaning |
|---|---|
* | Wildcard match |
= | Exact property match (e.g., [Category=Unit]) |
!= | Exclude property value |
& | AND (combine conditions) |
| | OR (within a segment, requires parentheses) |
Examples (TUnit):
# 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]"
VSTest → MTP filter translation (for migration)
MSTest, NUnit, and xUnit.net v2 (with YTest.MTP.XUnit2): The VSTest --filter syntax is identical on both VSTest and MTP. No changes needed.
xUnit.net v3 (native MTP): xUnit.net v3 does NOT support the VSTest --filter syntax on MTP. Translate filters using xUnit.net v3's native options:
VSTest --filter syntax | xUnit.net v3 MTP equivalent | Notes |
|---|---|---|
FullyQualifiedName~ClassName | --filter-class *ClassName* | Wildcards required for substring match |
FullyQualifiedName=Ns.Class.Method | --filter-method Ns.Class.Method | Exact match on fully qualified method |
Name=MethodName | --filter-method *MethodName* | Wildcards for substring match |
Category=Value (trait) | --filter-trait "Category=Value" | Filter by trait name/value pair |
| Complex expressions | --filter-query "expr" | Uses xUnit.net query filter language (see above) |
Frequently asked questions about Test Filter Syntax Reference
Similar skills
Spring Boot Testing
Master testing techniques for Spring Boot 4 applications.
GitHub Issues
Manage GitHub issues efficiently with MCP tools.
Geofeed Tuner
Optimize your IP geolocation feeds in CSV format.
Batch Files
Master Windows batch scripting for automation and task management.
Adobe Illustrator Scripting
Automate your Illustrator workflows with ExtendScript.
Plugin Structure
Create and organize Claude Code plugins effectively.
