[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYVPYF8XPYFZJRGSWG6JJA":3,"skill-same:01M6DYVPYF8XPYFZJRGSWG6JJA":89},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":58,"ownerDescription":59,"updatedAt":60,"install":61,"resources":74},"01M6DYVPYF8XPYFZJRGSWG6JJA","migrate-xunit-to-mstest",null,"Convert .NET tests from xUnit.net v2\u002Fv3 to MSTest v4 while preserving VSTest or MTP. Use for replacing xunit packages, Fact\u002FTheory\u002FInlineData\u002FMemberData, assertions, IClassFixture\u002FICollectionFixture, ITestOutputHelper, TestContext cancellation, traits\u002FOwner, skips, timeouts, and xUnit parallelization. Also use when a \"convert xUnit to MSTest\" request may already be migrated: inspect and report the no-op. Do not use for xUnit v2-to-v3, MSTest upgrades, NUnit\u002FTUnit conversion, or runner-only VSTest-to-MTP migration.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test-Migration\u002Fskills\u002Fmigrate-xunit-to-mstest\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"migrate","xunit","migrate xunit to mstest","mstest","conversion","when","request","for","inspect","traits","tunit","v3","tests","runner","do","migrated","migration","only","use","upgrades","parallelization","nunit","convert","report","packages","mtp","2026-11-10 10:12:30",false,"---\nname: migrate-xunit-to-mstest\ndescription: >\n  Convert .NET tests from xUnit.net v2\u002Fv3 to MSTest v4 while preserving VSTest\n  or MTP. Use for replacing xunit packages, Fact\u002FTheory\u002FInlineData\u002FMemberData,\n  assertions, IClassFixture\u002FICollectionFixture, ITestOutputHelper, TestContext\n  cancellation, traits\u002FOwner, skips, timeouts, and xUnit parallelization. Also\n  use when a \"convert xUnit to MSTest\" request may already be migrated: inspect\n  and report the no-op. Do not use for xUnit v2-to-v3, MSTest upgrades,\n  NUnit\u002FTUnit conversion, or runner-only VSTest-to-MTP migration.\nlicense: MIT\n---\n\n# xUnit -> MSTest Migration\n\nConvert xUnit.net v2 or v3 tests to MSTest v4 without changing the target framework or test platform. A successful migration builds, discovers the same tests, and preserves pass\u002Ffail results and execution semantics.\n\n## Scope\n\nUse this skill only when the project contains xUnit packages or source and the user wants MSTest. If the project already uses MSTest and contains no xUnit tests, report that no framework migration is needed and make no changes.\n\nDo not combine this framework conversion with a target-framework upgrade or VSTest\u002FMTP migration. Complete and verify one migration before starting another.\n\n## Workspace Contract\n\n- Continue after skill activation. Search the current working directory for the\n  staged project and source; never look for user files under this skill's base\n  directory.\n- Open the literal paths returned by glob\u002Fsearch. If one reader or patch tool\n  rejects a path that was just found, retry with another available tool. Do not\n  ask the user for a path until current-workspace discovery is exhausted.\n- Classify by the requested deliverable: \"convert this project\" means edit,\n  build, and test; \"give me a plan\" or \"how would I convert it?\" means answer.\n  Do not replace execution with \"please provide the files\" when files are present.\n- The final response must state the source xUnit version, preserved runner,\n  changed files, each high-risk semantic mapping applied, and actual test\n  counts. Assertions about fixture lifetime, Owner mapping, cancellation, or\n  parallelization must be visible in the resulting source, not only prose.\n\n## Response Mode\n\n- **Full migration request:** inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.\n- **Focused compile error or API question:** inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.\n- **Unsupported target framework:** stop before changing packages. MSTest v4 requires .NET 8+ or .NET Framework 4.6.2+ for test applications; offer a separately approved TFM upgrade or MSTest v3 as the intermediate target.\n\n## Decisions That Change the Result\n\nApply these before the mechanical mapping:\n\n| Detected state | Required action |\n|---|---|\n| No xUnit package, namespace, attribute, or fixture remains | Stop. Make no file changes, report that migration is unnecessary, and run the existing `dotnet test` command once to prove the already-MSTest project is healthy. |\n| Source uses VSTest | Keep the existing VSTest property\u002Fconfiguration. Prefer retaining and updating a source project's explicit `Microsoft.NET.Test.Sdk` pin; a repository that intentionally relies on the MSTest metapackage's transitive dependency may keep that convention. Do not introduce MTP properties. |\n| Source uses MTP | Replace xUnit-specific MTP selection with MSTest MTP configuration. Prefer `MSTest.Sdk`; with the metapackage, set `EnableMSTestRunner=true` and `OutputType=Exe`. Preserve native-versus-bridged command integration, and do not add `\u003CUseVSTest>true\u003C\u002FUseVSTest>` or other VSTest-only configuration. |\n| Source relies on xUnit's default parallelization | Add `[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]` to a compiled `.cs` file when the current project has at least two independently runnable test classes. In a one-class project with no explicit parallel setting, omit it because class-level concurrency is not observable. Translate explicit `CollectionBehavior` or `xunit.runner.json` settings regardless of current class count. Before reporting completion, read the changed file back and name it in the result. |\n\nFor detailed mappings and examples, search [`references\u002Fmapping-cheatsheet.md`](references\u002Fmapping-cheatsheet.md) for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.\n\n## Fast Path\n\nFor a routine project migration, converge in four phases: one batched discovery read\u002Fsearch, one edit pass, one `dotnet test`, and one concise result. Do not:\n\n- list a directory and then reread the same files through another tool\n- copy project files into the loaded skill or its `references\u002F` directory; those files are read-only guidance, not an editing workspace\n- try `dotnet test --no-restore` unless restore is already known to be current\n- run separate restore, build, and test commands when `dotnet test` is sufficient\n- rerun a passing test command or inspect unchanged files for confirmation\n\nUse an existing CI\u002Ftest result as the parity baseline when available. Run a new pre-edit baseline only when counts are unavailable and the migration contains data-driven tests, fixtures, skips, custom extensions, shared state, or other behavior whose parity cannot be established from source alone.\n\n## Workflow\n\n### 1. Establish the baseline\n\n1. In one discovery pass, batch-read the test projects plus `Directory.Build.props`, `Directory.Packages.props`, `global.json`, and runner configuration, and search the source for the high-risk constructs below.\n2. State the detected source version:\n   - `xunit` 2.x and related packages -> xUnit v2\n   - `xunit.v3` or `xunit.v3.*` -> xUnit v3\n3. Identify VSTest or MTP from the project and repository configuration. Use `platform-detection` only when the platform is ambiguous, and preserve the detected platform.\n4. Record the target frameworks and stop if MSTest v4 does not support them.\n5. If the Fast Path requires a new baseline, run the existing test command once and record discovered, passed, failed, and skipped counts.\n6. Inventory high-risk constructs before editing:\n   - `IClassFixture`, `ICollectionFixture`, `CollectionDefinition`, custom `FactAttribute`\u002F`TheoryAttribute`\u002F`DataAttribute`\n   - `Assert.Throws`, `ThrowsAny`, `IsType`, `Record.Exception`, event assertions\n   - `ITestOutputHelper`, `TestContext.Current`, `IAsyncLifetime`\n   - `CollectionBehavior`, `xunit.runner.json`, shared static or external state\n\n### 2. Replace packages without switching runners\n\nRemove xUnit packages from project files and central package files. This includes `xunit*`, `xunit.v3.*`, `xunit.runner.visualstudio`, `YTest.MTP.XUnit2`, and xUnit-specific companion packages that are being replaced.\n\nDefault to the MSTest v4 metapackage for an incremental conversion:\n\n```xml\n\u003C!-- Example pin: replace with the exact stable v4 version resolved from the configured package source. -->\n\u003CPackageReference Include=\"MSTest\" Version=\"4.1.0\" \u002F>\n```\n\nThe metapackage includes `Microsoft.NET.Test.Sdk`, `MSTest.TestAdapter`, `MSTest.TestFramework`, and `MSTest.Analyzers`. When preserving VSTest, prefer retaining a source project's explicit `Microsoft.NET.Test.Sdk` pin and update it to a version compatible with the chosen MSTest version; this keeps runner\u002Fversion compatibility reviewable. A repository that intentionally relies on the metapackage's transitive dependency may preserve that convention instead. For the example pin above, MSTest 4.1.0 requires Microsoft.NET.Test.Sdk 18.0.1+; incompatible older pins can cause `NU1605`.\n\nWhen preserving MTP, do not carry xUnit's `UseMicrosoftTestingPlatformRunner` property into the MSTest project. Prefer `MSTest.Sdk` at the resolved version. If repository conventions require the metapackage route, set `\u003CEnableMSTestRunner>true\u003C\u002FEnableMSTestRunner>` and `\u003COutputType>Exe\u003C\u002FOutputType>`. Retain `TestingPlatformDotnetTestSupport=true` only for repositories that continue to invoke MTP applications through VSTest command mode; native .NET 10+ MTP mode does not require it. When preserving VSTest with `MSTest.Sdk`, set `\u003CUseVSTest>true\u003C\u002FUseVSTest>`.\n\nDo not change `TargetFramework`. Remove `xunit.runner.json` only after porting its relevant settings.\n\n### 3. Perform the mechanical conversion\n\nApply the common rewrites first:\n\n| xUnit | MSTest |\n|---|---|\n| no class attribute | `[TestClass]` |\n| `[Fact]` | `[TestMethod]` |\n| `[Theory]` + `[InlineData]` | `[TestMethod]` + `[DataRow]` |\n| `[MemberData]` | `[DynamicData]` |\n| `[Fact(Skip = \"...\")]` | `[TestMethod]` + `[Ignore(\"...\")]` |\n| `[Trait(\"Category\", value)]` | `[TestCategory(value)]` |\n| `[Trait(\"Owner\", value)]` | `[Owner(value)]` |\n| other `[Trait(key, value)]` | `[TestProperty(key, value)]` |\n| `Assert.Equal` \u002F `NotEqual` | `Assert.AreEqual` \u002F `AreNotEqual` |\n| `Assert.True` \u002F `False` | `Assert.IsTrue` \u002F `IsFalse` |\n| `Assert.Null` \u002F `NotNull` | `Assert.IsNull` \u002F `IsNotNull` |\n\nRemove `using Xunit;` and `using Xunit.Abstractions;`. Add `using Microsoft.VisualStudio.TestTools.UnitTesting;` for the metapackage option; `MSTest.Sdk` supplies it as an implicit global using.\n\nPreserve existing class inheritance. Do not mechanically seal classes.\n\n### 4. Resolve semantic mappings\n\nLoad the mapping cheatsheet for every high-risk construct found in Step 1. These rules are mandatory:\n\n- xUnit `Assert.Throws\u003CT>` is exact-type and maps to MSTest `Assert.ThrowsExactly\u003CT>`.\n- xUnit `Assert.ThrowsAny\u003CT>` permits derived types and maps to MSTest `Assert.Throws\u003CT>`.\n- xUnit `Assert.IsType\u003CT>` is exact-type and maps to the generic `Assert.IsExactInstanceOfType\u003CT>`; `Assert.IsAssignableFrom\u003CT>` maps to the generic `Assert.IsInstanceOfType\u003CT>`. When the xUnit assertion's typed return value is assigned, preserve that assignment and use the generic MSTest overload rather than a non-generic `Type` overload.\n- xUnit `Assert.Equal` on sequences compares elements. Use `Assert.AreSequenceEqual` on MSTest 4.3+ or `CollectionAssert.AreEqual` with materialized lists on earlier v4; never replace sequence equality with reference-based `Assert.AreEqual`.\n- `[Ignore]` and `[Timeout]` are modifiers; keep `[TestMethod]` so the test is discovered.\n- `[DataRow]` values must exactly match parameter types.\n- `TestContext.Current.CancellationToken` maps to an injected MSTest `TestContext.CancellationToken`; never replace it with `CancellationToken.None` or a new `CancellationTokenSource`.\n- `Owner` is a reserved VSTest property. Map `[Trait(\"Owner\", value)]` to `[Owner(value)]`, not `[TestProperty(\"Owner\", value)]`.\n- Assertions with no MSTest equivalent (`Assert.Collection`, `Assert.All`, `Assert.Equivalent`, `Record.Exception`, event assertions) require an explicit manual rewrite. Never delete an assertion without replacing its verification.\n\nApply the mechanical and semantic rewrites in one edit pass when the inventory makes the required mappings clear. Do not run an intermediate build by default; use compiler errors from final verification to drive only unresolved conversions.\n\n### 5. Preserve lifecycle, fixture scope, and parallelization\n\n- Keep constructor setup and `IDisposable`\u002F`IAsyncDisposable` when valid. Map `IAsyncLifetime` to `[TestInitialize]`\u002F`[TestCleanup]`.\n- `IClassFixture\u003CT>` means one fixture instance per test class, shared by all methods in that class. Map it to a static `T` field created once by a static `[ClassInitialize]` method that accepts `TestContext`, and dispose it once from static `[ClassCleanup]`. Never use `[TestInitialize]`\u002F`[TestCleanup]` for this mapping because that creates one fixture per test method.\n- For `ICollectionFixture\u003CT>`, preserve both sharing and serialization. Prefer a static `Lazy\u003CT>` helper used by each member class; add `[DoNotParallelize]` only when the source collection disabled parallelization. Use assembly initialization only when the fixture is genuinely assembly-wide.\n- Replace `ITestOutputHelper` with constructor-injected or property-based MSTest `TestContext`, and replace each `_output.WriteLine(...)` call with the corresponding `TestContext.WriteLine(...)`. In the final result, name both the `TestContext` injection\u002Fproperty and the `WriteLine` mapping explicitly; \"migrated output\" is not enough to demonstrate parity.\n\nxUnit runs classes in parallel by default; MSTest runs them serially. When the current project has two or more independently runnable test classes, preserve that effective behavior with:\n\n```csharp\n[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]\n```\n\nFor a one-class project with no explicit xUnit parallel setting, do not add an assembly policy: there is no class-level concurrency to preserve. Always translate explicit `CollectionBehavior` or `xunit.runner.json` settings. Never use `ExecutionScope.MethodLevel` to emulate xUnit. Before applying a fixture-scope or parallelization decision, state what the source shared or serialized and how the target preserves it.\n\n### 6. Verify parity\n\n1. Run tests once with the same platform, filter, and configuration used for the baseline. `dotnet test` builds by default; run a separate build only when needed to isolate a compilation failure.\n2. Compare discovered, passed, failed, and skipped counts.\n3. Investigate every difference before declaring completion:\n   - missing cases -> discovery attributes, `DynamicData`, or `DataRow` literal types\n   - changed exception behavior -> exact-vs-derived assertion mapping\n   - shared-state failures or large duration changes -> fixture scope and parallelization\n   - silently skipped tests -> missing `[TestMethod]` or incorrect runtime-skip conversion\n4. Confirm no xUnit package, namespace, attribute, runner configuration, or fixture interface remains unless explicitly documented for manual follow-up.\n5. After the final passing test, read back each changed file that implements a high-risk mapping, plus any runner or parallelization configuration. In the result, name the file and the exact target APIs that implement its lifecycle, data, skip, output, assertion, fixture-scope, or parallelization behavior. Preserve type arguments and member names such as `[ClassInitialize]`, `TestContext.WriteLine`, and `Assert.IsExactInstanceOfType\u003CT>`; generic claims such as \"converted attributes\" or \"migrated output\" are not evidence of parity.\n\nKeep the final response concise and outcome-focused:\n\n- **Changed:** name the files and exact high-risk mappings applied.\n- **Verified:** give the final test command and discovered\u002Fpassed\u002Ffailed\u002Fskipped counts.\n- **Preserved:** state the unchanged target framework and test platform, plus any fixture or parallelization scope decision.\n- **Remaining:** identify manual follow-up, or say none.\n\n## Completion Criteria\n\n- Current xUnit version and test platform were identified\n- xUnit packages and source constructs were converted\n- Target framework and test platform stayed unchanged\n- Fixture scope and effective parallelization decisions are explicit, including justified omission when concurrency is not observable\n- Build succeeds\n- Test discovery and result counts match the baseline\n- Any unsupported custom extension point is called out rather than approximated\n\n## Follow-up\n\nRun `migrate-vstest-to-mtp` separately if the user also wants MTP. Use `writing-mstest-tests` only after parity is established to polish the converted MSTest code.\n","# xUnit -> MSTest Migration\n\nConvert xUnit.net v2 or v3 tests to MSTest v4 without changing the target framework or test platform. A successful migration builds, discovers the same tests, and preserves pass\u002Ffail results and execution semantics.\n\n## Scope\n\nUse this skill only when the project contains xUnit packages or source and the user wants MSTest. If the project already uses MSTest and contains no xUnit tests, report that no framework migration is needed and make no changes.\n\nDo not combine this framework conversion with a target-framework upgrade or VSTest\u002FMTP migration. Complete and verify one migration before starting another.\n\n## Workspace Contract\n\n- Continue after skill activation. Search the current working directory for the\n  staged project and source; never look for user files under this skill's base\n  directory.\n- Open the literal paths returned by glob\u002Fsearch. If one reader or patch tool\n  rejects a path that was just found, retry with another available tool. Do not\n  ask the user for a path until current-workspace discovery is exhausted.\n- Classify by the requested deliverable: \"convert this project\" means edit,\n  build, and test; \"give me a plan\" or \"how would I convert it?\" means answer.\n  Do not replace execution with \"please provide the files\" when files are present.\n- The final response must state the source xUnit version, preserved runner,\n  changed files, each high-risk semantic mapping applied, and actual test\n  counts. Assertions about fixture lifetime, Owner mapping, cancellation, or\n  parallelization must be visible in the resulting source, not only prose.\n\n## Response Mode\n\n- **Full migration request:** inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.\n- **Focused compile error or API question:** inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.\n- **Unsupported target framework:** stop before changing packages. MSTest v4 requires .NET 8+ or .NET Framework 4.6.2+ for test applications; offer a separately approved TFM upgrade or MSTest v3 as the intermediate target.\n\n## Decisions That Change the Result\n\nApply these before the mechanical mapping:\n\n| Detected state | Required action |\n|---|---|\n| No xUnit package, namespace, attribute, or fixture remains | Stop. Make no file changes, report that migration is unnecessary, and run the existing `dotnet test` command once to prove the already-MSTest project is healthy. |\n| Source uses VSTest | Keep the existing VSTest property\u002Fconfiguration. Prefer retaining and updating a source project's explicit `Microsoft.NET.Test.Sdk` pin; a repository that intentionally relies on the MSTest metapackage's transitive dependency may keep that convention. Do not introduce MTP properties. |\n| Source uses MTP | Replace xUnit-specific MTP selection with MSTest MTP configuration. Prefer `MSTest.Sdk`; with the metapackage, set `EnableMSTestRunner=true` and `OutputType=Exe`. Preserve native-versus-bridged command integration, and do not add `\u003CUseVSTest>true\u003C\u002FUseVSTest>` or other VSTest-only configuration. |\n| Source relies on xUnit's default parallelization | Add `[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]` to a compiled `.cs` file when the current project has at least two independently runnable test classes. In a one-class project with no explicit parallel setting, omit it because class-level concurrency is not observable. Translate explicit `CollectionBehavior` or `xunit.runner.json` settings regardless of current class count. Before reporting completion, read the changed file back and name it in the result. |\n\nFor detailed mappings and examples, search [`references\u002Fmapping-cheatsheet.md`](references\u002Fmapping-cheatsheet.md) for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.\n\n## Fast Path\n\nFor a routine project migration, converge in four phases: one batched discovery read\u002Fsearch, one edit pass, one `dotnet test`, and one concise result. Do not:\n\n- list a directory and then reread the same files through another tool\n- copy project files into the loaded skill or its `references\u002F` directory; those files are read-only guidance, not an editing workspace\n- try `dotnet test --no-restore` unless restore is already known to be current\n- run separate restore, build, and test commands when `dotnet test` is sufficient\n- rerun a passing test command or inspect unchanged files for confirmation\n\nUse an existing CI\u002Ftest result as the parity baseline when available. Run a new pre-edit baseline only when counts are unavailable and the migration contains data-driven tests, fixtures, skips, custom extensions, shared state, or other behavior whose parity cannot be established from source alone.\n\n## Workflow\n\n### 1. Establish the baseline\n\n1. In one discovery pass, batch-read the test projects plus `Directory.Build.props`, `Directory.Packages.props`, `global.json`, and runner configuration, and search the source for the high-risk constructs below.\n2. State the detected source version:\n   - `xunit` 2.x and related packages -> xUnit v2\n   - `xunit.v3` or `xunit.v3.*` -> xUnit v3\n3. Identify VSTest or MTP from the project and repository configuration. Use `platform-detection` only when the platform is ambiguous, and preserve the detected platform.\n4. Record the target frameworks and stop if MSTest v4 does not support them.\n5. If the Fast Path requires a new baseline, run the existing test command once and record discovered, passed, failed, and skipped counts.\n6. Inventory high-risk constructs before editing:\n   - `IClassFixture`, `ICollectionFixture`, `CollectionDefinition`, custom `FactAttribute`\u002F`TheoryAttribute`\u002F`DataAttribute`\n   - `Assert.Throws`, `ThrowsAny`, `IsType`, `Record.Exception`, event assertions\n   - `ITestOutputHelper`, `TestContext.Current`, `IAsyncLifetime`\n   - `CollectionBehavior`, `xunit.runner.json`, shared static or external state\n\n### 2. Replace packages without switching runners\n\nRemove xUnit packages from project files and central package files. This includes `xunit*`, `xunit.v3.*`, `xunit.runner.visualstudio`, `YTest.MTP.XUnit2`, and xUnit-specific companion packages that are being replaced.\n\nDefault to the MSTest v4 metapackage for an incremental conversion:\n\n```xml\n\u003C!-- Example pin: replace with the exact stable v4 version resolved from the configured package source. -->\n\u003CPackageReference Include=\"MSTest\" Version=\"4.1.0\" \u002F>\n```\n\nThe metapackage includes `Microsoft.NET.Test.Sdk`, `MSTest.TestAdapter`, `MSTest.TestFramework`, and `MSTest.Analyzers`. When preserving VSTest, prefer retaining a source project's explicit `Microsoft.NET.Test.Sdk` pin and update it to a version compatible with the chosen MSTest version; this keeps runner\u002Fversion compatibility reviewable. A repository that intentionally relies on the metapackage's transitive dependency may preserve that convention instead. For the example pin above, MSTest 4.1.0 requires Microsoft.NET.Test.Sdk 18.0.1+; incompatible older pins can cause `NU1605`.\n\nWhen preserving MTP, do not carry xUnit's `UseMicrosoftTestingPlatformRunner` property into the MSTest project. Prefer `MSTest.Sdk` at the resolved version. If repository conventions require the metapackage route, set `\u003CEnableMSTestRunner>true\u003C\u002FEnableMSTestRunner>` and `\u003COutputType>Exe\u003C\u002FOutputType>`. Retain `TestingPlatformDotnetTestSupport=true` only for repositories that continue to invoke MTP applications through VSTest command mode; native .NET 10+ MTP mode does not require it. When preserving VSTest with `MSTest.Sdk`, set `\u003CUseVSTest>true\u003C\u002FUseVSTest>`.\n\nDo not change `TargetFramework`. Remove `xunit.runner.json` only after porting its relevant settings.\n\n### 3. Perform the mechanical conversion\n\nApply the common rewrites first:\n\n| xUnit | MSTest |\n|---|---|\n| no class attribute | `[TestClass]` |\n| `[Fact]` | `[TestMethod]` |\n| `[Theory]` + `[InlineData]` | `[TestMethod]` + `[DataRow]` |\n| `[MemberData]` | `[DynamicData]` |\n| `[Fact(Skip = \"...\")]` | `[TestMethod]` + `[Ignore(\"...\")]` |\n| `[Trait(\"Category\", value)]` | `[TestCategory(value)]` |\n| `[Trait(\"Owner\", value)]` | `[Owner(value)]` |\n| other `[Trait(key, value)]` | `[TestProperty(key, value)]` |\n| `Assert.Equal` \u002F `NotEqual` | `Assert.AreEqual` \u002F `AreNotEqual` |\n| `Assert.True` \u002F `False` | `Assert.IsTrue` \u002F `IsFalse` |\n| `Assert.Null` \u002F `NotNull` | `Assert.IsNull` \u002F `IsNotNull` |\n\nRemove `using Xunit;` and `using Xunit.Abstractions;`. Add `using Microsoft.VisualStudio.TestTools.UnitTesting;` for the metapackage option; `MSTest.Sdk` supplies it as an implicit global using.\n\nPreserve existing class inheritance. Do not mechanically seal classes.\n\n### 4. Resolve semantic mappings\n\nLoad the mapping cheatsheet for every high-risk construct found in Step 1. These rules are mandatory:\n\n- xUnit `Assert.Throws\u003CT>` is exact-type and maps to MSTest `Assert.ThrowsExactly\u003CT>`.\n- xUnit `Assert.ThrowsAny\u003CT>` permits derived types and maps to MSTest `Assert.Throws\u003CT>`.\n- xUnit `Assert.IsType\u003CT>` is exact-type and maps to the generic `Assert.IsExactInstanceOfType\u003CT>`; `Assert.IsAssignableFrom\u003CT>` maps to the generic `Assert.IsInstanceOfType\u003CT>`. When the xUnit assertion's typed return value is assigned, preserve that assignment and use the generic MSTest overload rather than a non-generic `Type` overload.\n- xUnit `Assert.Equal` on sequences compares elements. Use `Assert.AreSequenceEqual` on MSTest 4.3+ or `CollectionAssert.AreEqual` with materialized lists on earlier v4; never replace sequence equality with reference-based `Assert.AreEqual`.\n- `[Ignore]` and `[Timeout]` are modifiers; keep `[TestMethod]` so the test is discovered.\n- `[DataRow]` values must exactly match parameter types.\n- `TestContext.Current.CancellationToken` maps to an injected MSTest `TestContext.CancellationToken`; never replace it with `CancellationToken.None` or a new `CancellationTokenSource`.\n- `Owner` is a reserved VSTest property. Map `[Trait(\"Owner\", value)]` to `[Owner(value)]`, not `[TestProperty(\"Owner\", value)]`.\n- Assertions with no MSTest equivalent (`Assert.Collection`, `Assert.All`, `Assert.Equivalent`, `Record.Exception`, event assertions) require an explicit manual rewrite. Never delete an assertion without replacing its verification.\n\nApply the mechanical and semantic rewrites in one edit pass when the inventory makes the required mappings clear. Do not run an intermediate build by default; use compiler errors from final verification to drive only unresolved conversions.\n\n### 5. Preserve lifecycle, fixture scope, and parallelization\n\n- Keep constructor setup and `IDisposable`\u002F`IAsyncDisposable` when valid. Map `IAsyncLifetime` to `[TestInitialize]`\u002F`[TestCleanup]`.\n- `IClassFixture\u003CT>` means one fixture instance per test class, shared by all methods in that class. Map it to a static `T` field created once by a static `[ClassInitialize]` method that accepts `TestContext`, and dispose it once from static `[ClassCleanup]`. Never use `[TestInitialize]`\u002F`[TestCleanup]` for this mapping because that creates one fixture per test method.\n- For `ICollectionFixture\u003CT>`, preserve both sharing and serialization. Prefer a static `Lazy\u003CT>` helper used by each member class; add `[DoNotParallelize]` only when the source collection disabled parallelization. Use assembly initialization only when the fixture is genuinely assembly-wide.\n- Replace `ITestOutputHelper` with constructor-injected or property-based MSTest `TestContext`, and replace each `_output.WriteLine(...)` call with the corresponding `TestContext.WriteLine(...)`. In the final result, name both the `TestContext` injection\u002Fproperty and the `WriteLine` mapping explicitly; \"migrated output\" is not enough to demonstrate parity.\n\nxUnit runs classes in parallel by default; MSTest runs them serially. When the current project has two or more independently runnable test classes, preserve that effective behavior with:\n\n```csharp\n[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]\n```\n\nFor a one-class project with no explicit xUnit parallel setting, do not add an assembly policy: there is no class-level concurrency to preserve. Always translate explicit `CollectionBehavior` or `xunit.runner.json` settings. Never use `ExecutionScope.MethodLevel` to emulate xUnit. Before applying a fixture-scope or parallelization decision, state what the source shared or serialized and how the target preserves it.\n\n### 6. Verify parity\n\n1. Run tests once with the same platform, filter, and configuration used for the baseline. `dotnet test` builds by default; run a separate build only when needed to isolate a compilation failure.\n2. Compare discovered, passed, failed, and skipped counts.\n3. Investigate every difference before declaring completion:\n   - missing cases -> discovery attributes, `DynamicData`, or `DataRow` literal types\n   - changed exception behavior -> exact-vs-derived assertion mapping\n   - shared-state failures or large duration changes -> fixture scope and parallelization\n   - silently skipped tests -> missing `[TestMethod]` or incorrect runtime-skip conversion\n4. Confirm no xUnit package, namespace, attribute, runner configuration, or fixture interface remains unless explicitly documented for manual follow-up.\n5. After the final passing test, read back each changed file that implements a high-risk mapping, plus any runner or parallelization configuration. In the result, name the file and the exact target APIs that implement its lifecycle, data, skip, output, assertion, fixture-scope, or parallelization behavior. Preserve type arguments and member names such as `[ClassInitialize]`, `TestContext.WriteLine`, and `Assert.IsExactInstanceOfType\u003CT>`; generic claims such as \"converted attributes\" or \"migrated output\" are not evidence of parity.\n\nKeep the final response concise and outcome-focused:\n\n- **Changed:** name the files and exact high-risk mappings applied.\n- **Verified:** give the final test command and discovered\u002Fpassed\u002Ffailed\u002Fskipped counts.\n- **Preserved:** state the unchanged target framework and test platform, plus any fixture or parallelization scope decision.\n- **Remaining:** identify manual follow-up, or say none.\n\n## Completion Criteria\n\n- Current xUnit version and test platform were identified\n- xUnit packages and source constructs were converted\n- Target framework and test platform stayed unchanged\n- Fixture scope and effective parallelization decisions are explicit, including justified omission when concurrency is not observable\n- Build succeeds\n- Test discovery and result counts match the baseline\n- Any unsupported custom extension point is called out rather than approximated\n\n## Follow-up\n\nRun `migrate-vstest-to-mtp` separately if the user also wants MTP. Use `writing-mstest-tests` only after parity is established to polish the converted MSTest code.\n",{"name":5,"license":15,"description":50},"Convert .NET tests from xUnit.net v2\u002Fv3 to MSTest v4 while preserving VSTest or MTP. Use for replacing xunit packages, Fact\u002FTheory\u002FInlineData\u002FMemberData, assertions, IClassFixture\u002FICollectionFixture, ITestOutputHelper, TestContext cancellation, traits\u002FOwner, skips, timeouts, and xUnit parallelization. Also use when a \"convert xUnit to MSTest\" request may already be migrated: inspect and report the no-op. Do not use for xUnit v2-to-v3, MSTest upgrades, NUnit\u002FTUnit conversion, or runner-only VSTest-to-MTP migration.\n","main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FTesting\u002FOfficial-DotNet-Test-Migration\u002Fskills\u002Fmigrate-xunit-to-mstest",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add managedcode\u002Fdotnet-skills --skill migrate-xunit-to-mstest",{"tool":67,"command":68},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill migrate-xunit-to-mstest",{"tool":70,"command":71},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill migrate-xunit-to-mstest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test-Migration\u002Fskills\u002Fmigrate-xunit-to-mstest\u002FSKILL.md",true,[75,81,85],{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"manifest.json","REFERENCE","参考文档",178,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test-Migration\u002Fskills\u002Fmigrate-xunit-to-mstest\u002Fmanifest.json",{"path":82,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Flanguages.md",4786,"https:\u002F\u002Fgithub.com\u002Fgjbvsjjvgm-sketch\u002Fhermes-sovereign-unified-v13.6\u002Fblob\u002Fmain\u002Fhermes_sovereign_data\u002Fskills\u002Fmlops\u002Fmodels\u002Fwhisper\u002Freferences\u002Flanguages.md",{"path":86,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fmapping-cheatsheet.md",28043,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FOfficial-DotNet-Test-Migration\u002Fskills\u002Fmigrate-xunit-to-mstest\u002Freferences\u002Fmapping-cheatsheet.md",[90,127,151,180,190,216],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":106,"publishedAt":45},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[96,101],{"categoryNo":97,"categoryName":98,"taxonomyType":99,"taxonomyTypeDesc":100},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":102,"categoryName":103,"taxonomyType":104,"taxonomyTypeDesc":105},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126],"xtwitter scraper","browser automation","workflows","run","code","browser","search","repository","api","Media","api client","access","edit","unrelated","webhooks","files","social","commands","modeling","webhook",{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":139,"publishedAt":45},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[133,136],{"categoryNo":134,"categoryName":135,"taxonomyType":99,"taxonomyTypeDesc":100},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":137,"categoryName":138,"taxonomyType":104,"taxonomyTypeDesc":105},"01JBSEEDCAT000000000000036","内容创作者",[129,140,141,109,142,110,114,143,144,145,119,146,120,122,33,147,148,149,124,150],"writing","performance","tasks","data","parsing","parser","context","writer","options","project","high-performance",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":45},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[158,159,160,161,162,163,164,165,166,167,168,169,37,170,171,172,173,174,175,176,26,177,178,179,24],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","language","three","compute","post","processing","with","renderer","materials","wgsl","effects",{"skillNo":181,"name":182,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":45},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[182,37,122,187,188,26,189],"semantic","razor","inspection",{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":196,"publishedAt":45},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[197,198,199,200,140,201,202,203,204,205,206,37,36,207,208,209,33,210,211,212,213,26,214,215,24],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","probe","guidance","later","type","dictionary","naming","targeting","custom","generic",{"skillNo":217,"name":218,"nameZh":6,"description":219,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":220,"categories":221,"keywords":224,"publishedAt":45},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[222,223],{"categoryNo":97,"categoryName":98,"taxonomyType":99,"taxonomyTypeDesc":100},{"categoryNo":102,"categoryName":103,"taxonomyType":104,"taxonomyTypeDesc":105},[115,225,226,227,110,228,165,197,37,208,209,33,229,230,231,232,213,26,233],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]