{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/filter-syntax",
  "version": "1.0.0",
  "name": "filter-syntax",
  "description": "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.",
  "system_prompt_fragment": "# Test Filter Syntax Reference\n\nFilter syntax depends on the **platform** and **test framework**.\n\n## VSTest filters (MSTest, xUnit v2, NUnit on VSTest)\n\n```bash\ndotnet test --filter <EXPRESSION>\n```\n\nExpression syntax: `<Property><Operator><Value>[|&<Expression>]`\n\n**Operators:**\n\n| Operator | Meaning |\n|----------|---------|\n| `=` | Exact match |\n| `!=` | Not exact match |\n| `~` | Contains |\n| `!~` | Does not contain |\n\n**Combinators:** `|` (OR), `&` (AND). Parentheses for grouping: `(A|B)&C`\n\n**Supported properties by framework:**\n\n| Framework | Properties |\n|-----------|-----------|\n| MSTest | `FullyQualifiedName`, `Name`, `ClassName`, `Priority`, `TestCategory` |\n| xUnit | `FullyQualifiedName`, `DisplayName`, `Traits` |\n| NUnit | `FullyQualifiedName`, `Name`, `Priority`, `TestCategory` |\n\nAn expression without an operator is treated as `FullyQualifiedName~<value>`.\n\n**Examples (VSTest):**\n\n```bash\n# Run tests whose name contains \"LoginTest\"\ndotnet test --filter \"Name~LoginTest\"\n\n# Run a specific test class\ndotnet test --filter \"ClassName=MyNamespace.MyTestClass\"\n\n# Run tests in a category\ndotnet test --filter \"TestCategory=Integration\"\n\n# Exclude a category\ndotnet test --filter \"TestCategory!=Slow\"\n\n# Combine: class AND category\ndotnet test --filter \"ClassName=MyNamespace.MyTestClass&TestCategory=Unit\"\n\n# Either of two classes\ndotnet test --filter \"ClassName=MyNamespace.ClassA|ClassName=MyNamespace.ClassB\"\n```\n\n## MTP filters — MSTest and NUnit\n\nMSTest 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:\n\n```bash\n# .NET SDK 8/9 (after --)\ndotnet test -- --filter \"Name~LoginTest\"\n\n# .NET SDK 10+ (direct)\ndotnet test --filter \"Name~LoginTest\"\n```\n\n## MTP filters — xUnit (v3)\n\nxUnit v3 on MTP uses **framework-specific filter flags** instead of the generic `--filter` expression:\n\n| Flag | Description |\n|------|-------------|\n| `--filter-class \"name\"` | Run all tests in a given class |\n| `--filter-not-class \"name\"` | Exclude all tests in a given class |\n| `--filter-method \"name\"` | Run a specific test method |\n| `--filter-not-method \"name\"` | Exclude a specific test method |\n| `--filter-namespace \"name\"` | Run all tests in a namespace |\n| `--filter-not-namespace \"name\"` | Exclude all tests in a namespace |\n| `--filter-trait \"name=value\"` | Run tests with a matching trait |\n| `--filter-not-trait \"name=value\"` | Exclude tests with a matching trait |\n\nMultiple values can be specified with a single flag: `--filter-class Foo Bar`.\n\n```bash\n# .NET SDK 8/9\ndotnet test -- --filter-class \"MyNamespace.LoginTests\"\n\n# .NET SDK 10+\ndotnet test --filter-class \"MyNamespace.LoginTests\"\n\n# Combine: namespace + trait\ndotnet test --filter-namespace \"MyApp.Tests.Integration\" --filter-trait \"Category=Smoke\"\n```\n\n### xUnit v3 query filter language\n\nFor complex expressions, use `--filter-query` with a path-segment syntax:\n\n```text\n/<assemblyFilter>/<namespaceFilter>/<classFilter>/<methodFilter>[traitName=traitValue]\n```\n\nEach 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>\n\n```shell\n# xUnit.net v3 MTP — using query language (assembly/namespace/class/method[trait])\ndotnet test -- --filter-query \"/*/*/*IntegrationTests*/*[Category=Smoke]\"\n```\n\n## MTP filters — TUnit\n\nTUnit uses `--treenode-filter` with a path-based syntax:\n\n```text\n--treenode-filter \"/<Assembly>/<Namespace>/<ClassName>/<TestName>\"\n```\n\nWildcards (`*`) are supported in any segment. Filter operators can be appended to test names for property-based filtering.\n\n| Operator | Meaning |\n|----------|---------|\n| `*` | Wildcard match |\n| `=` | Exact property match (e.g., `[Category=Unit]`) |\n| `!=` | Exclude property value |\n| `&` | AND (combine conditions) |\n| `\\|` | OR (within a segment, requires parentheses) |\n\n**Examples (TUnit):**\n\n```bash\n# All tests in a class\ndotnet run --treenode-filter \"/*/*/LoginTests/*\"\n\n# A specific test\ndotnet run --treenode-filter \"/*/*/*/AcceptCookiesTest\"\n\n# By namespace prefix (wildcard)\ndotnet run --treenode-filter \"/*/MyProject.Tests.Api*/*/*\"\n\n# By custom property\ndotnet run --treenode-filter \"/*/*/*/*[Category=Smoke]\"\n\n# Exclude by property\ndotnet run --treenode-filter \"/*/*/*/*[Category!=Slow]\"\n\n# OR across classes\ndotnet run --treenode-filter \"/*/*/(LoginTests)|(SignupTests)/*\"\n\n# Combined: namespace + property\ndotnet run --treenode-filter \"/*/MyProject.Tests.Integration/*/*/*[Priority=Critical]\"\n```\n\n## VSTest → MTP filter translation (for migration)\n\n**MSTest, NUnit, and xUnit.net v2 (with `YTest.MTP.XUnit2`)**: The VSTest `--filter` syntax is identical on both VSTest and MTP. No changes needed.\n\n**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:\n\n| VSTest `--filter` syntax | xUnit.net v3 MTP equivalent | Notes |\n|---|---|---|\n| `FullyQualifiedName~ClassName` | `--filter-class *ClassName*` | Wildcards required for substring match |\n| `FullyQualifiedName=Ns.Class.Method` | `--filter-method Ns.Class.Method` | Exact match on fully qualified method |\n| `Name=MethodName` | `--filter-method *MethodName*` | Wildcards for substring match |\n| `Category=Value` (trait) | `--filter-trait \"Category=Value\"` | Filter by trait name/value pair |\n| Complex expressions | `--filter-query \"expr\"` | Uses xUnit.net query filter language (see above) |",
  "applicable_domains": [
    "code",
    "dotnet",
    "engineering"
  ],
  "invocation": [
    "/filter-syntax"
  ],
  "tags": [
    "dotnet-test",
    "dotnet",
    "csharp",
    "microsoft"
  ],
  "authored_by": "anthropics",
  "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/filter-syntax/SKILL.md",
  "lifecycle": "stable",
  "category": "dotnet",
  "provenance": {
    "source": "dotnet/skills",
    "source_url": "https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/filter-syntax/SKILL.md",
    "author": "Microsoft / .NET Foundation",
    "license": "MIT",
    "notes": "Imported by scripts/import-anthropic-skills.py."
  }
}