Source profileQuality 90/100Review permissions

dotnet/skills/plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.md

migrate-xunit-to-mstest

Convert .NET test projects from xUnit.net v2 or v3 to MSTest v4. Use for replacing xunit packages, [Fact]/[Theory], xUnit assertions, fixtures, ITestOutputHelper, traits, skips, and xUnit parallelization with MSTest equivalents while preserving the current VSTest or MTP runner. DO NOT USE FOR: xUnit v2 to v3 upgrades, MSTest version upgrades, migrations from NUnit/TUnit, or runner-only VSTest to MTP migrations.

Source repository stars
5,277
Declared platforms
0
Static risk flags
2
Last source update
2026-08-28
Source checked
2026-08-28

Decision brief

What it does: where it fits

Convert 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/fail results and execution semantics.

Best for

    Not for

    • DO NOT USE FOR: xUnit v2 to v3 upgrades, MSTest version upgrades, migrations from NUnit/TUnit, or runner-only VSTest to MTP migrations.

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexNot declaredNo explicit evidencePortability before use
    Claude CodeNot declaredNo explicit evidencePortability before use
    CursorNot declaredNo explicit evidencePortability before use
    Gemini CLINot declaredNo explicit evidencePortability before use
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/dotnet/skills --skill "plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest"
    Safe inspection promptEditorial

    Inspect the Agent Skill "migrate-xunit-to-mstest" from https://github.com/dotnet/skills/blob/2b9056bd9152490cc698c5b3e61c9f9a1c135776/plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.md at commit 2b9056bd9152490cc698c5b3e61c9f9a1c135776. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Workflow

      1. 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. 2. State the detected source version: - xunit 2.x and related packages -…

      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.State the detected source version:xunit 2.x and related packages - xUnit v2
    2. 02

      Scope

      Use 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.

      Use 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…Do not combine this framework conversion with a target-framework upgrade or VSTest/MTP migration. Complete and verify one migration before starting another.
    3. 03

      Response Mode

      Full migration request: inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.

      Full migration request: inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.Focused compile error or API question: inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.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.
    4. 04

      Decisions That Change the Result

      Apply these before the mechanical mapping:

      Apply these before the mechanical mapping:For detailed mappings and examples, search references/mapping-cheatsheet.md for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.
    5. 05

      Fast Path

      For a routine project migration, converge in four phases: one batched discovery read/search, one edit pass, one dotnet test, and one concise result. Do not:

      list a directory and then reread the same files through another tooltry dotnet test --no-restore unless restore is already known to be currentrun separate restore, build, and test commands when dotnet test is sufficient

    Permission review

    Static risk signals and limitations

    Runs scripts

    medium · line 24

    The documentation asks the agent to run terminal commands or scripts.

    | 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. |

    Reads files

    low · line 27

    The documentation asks the agent to read local files, directories, or repositories.

    | Source uses xUnit's default parallelization | Add `[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]` to a compiled `.cs` file. Before reporting completion, read that file back and name it in the result; merely sayin

    Reads files

    low · line 46

    The documentation asks the agent to read local files, directories, or repositories.

    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.

    Runs scripts

    medium · line 52

    The documentation asks the agent to run terminal commands or scripts.

    If the Fast Path requires a new baseline, run the existing test command once and record discovered, passed, failed, and skipped counts.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score90/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars5,277SourceRepository attention, not individual Skill quality
    Compatibility0 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    dotnet/skills
    Skill path
    plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.md
    Commit
    2b9056bd9152490cc698c5b3e61c9f9a1c135776
    License
    MIT
    Collected
    2026-08-28
    Default branch
    main
    View the original SKILL.md

    xUnit -> MSTest Migration

    Convert 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/fail results and execution semantics.

    Scope

    Use 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.

    Do not combine this framework conversion with a target-framework upgrade or VSTest/MTP migration. Complete and verify one migration before starting another.

    Response Mode

    • Full migration request: inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.
    • Focused compile error or API question: inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.
    • 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.

    Decisions That Change the Result

    Apply these before the mechanical mapping:

    Detected stateRequired action
    No xUnit package, namespace, attribute, or fixture remainsStop. 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.
    Source uses VSTestKeep the existing VSTest property/configuration. 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.
    Source uses MTPReplace 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 <UseVSTest>true</UseVSTest> or other VSTest-only configuration.
    Source uses xUnit's default parallelizationAdd [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)] to a compiled .cs file. Before reporting completion, read that file back and name it in the result; merely saying parallelization was preserved is insufficient.

    For detailed mappings and examples, search references/mapping-cheatsheet.md for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.

    Fast Path

    For a routine project migration, converge in four phases: one batched discovery read/search, one edit pass, one dotnet test, and one concise result. Do not:

    • list a directory and then reread the same files through another tool
    • try dotnet test --no-restore unless restore is already known to be current
    • run separate restore, build, and test commands when dotnet test is sufficient
    • rerun a passing test command or inspect unchanged files for confirmation

    Use an existing CI/test 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.

    Workflow

    1. Establish the baseline

    1. 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.
    2. State the detected source version:
      • xunit 2.x and related packages -> xUnit v2
      • xunit.v3 or xunit.v3.* -> xUnit v3
    3. Identify VSTest or MTP from the project and repository configuration. Use platform-detection only when the platform is ambiguous, and preserve the detected platform.
    4. Record the target frameworks and stop if MSTest v4 does not support them.
    5. If the Fast Path requires a new baseline, run the existing test command once and record discovered, passed, failed, and skipped counts.
    6. Inventory high-risk constructs before editing:
      • IClassFixture, ICollectionFixture, CollectionDefinition, custom FactAttribute/TheoryAttribute/DataAttribute
      • Assert.Throws, ThrowsAny, IsType, Record.Exception, event assertions
      • ITestOutputHelper, TestContext.Current, IAsyncLifetime
      • CollectionBehavior, xunit.runner.json, shared static or external state

    2. Replace packages without switching runners

    Remove 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.

    Default to the MSTest v4 metapackage for an incremental conversion:

    <!-- Example pin: replace with the exact stable v4 version resolved from the configured package source. -->
    <PackageReference Include="MSTest" Version="4.1.0" />
    

    The 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/version 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.

    When 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 <EnableMSTestRunner>true</EnableMSTestRunner> and <OutputType>Exe</OutputType>. 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 <UseVSTest>true</UseVSTest>.

    Do not change TargetFramework. Remove xunit.runner.json only after porting its relevant settings.

    3. Perform the mechanical conversion

    Apply the common rewrites first:

    xUnitMSTest
    no class attribute[TestClass]
    [Fact][TestMethod]
    [Theory] + [InlineData][TestMethod] + [DataRow]
    [MemberData][DynamicData]
    [Fact(Skip = "...")][TestMethod] + [Ignore("...")]
    [Trait("Category", value)][TestCategory(value)]
    [Trait("Owner", value)][Owner(value)]
    other [Trait(key, value)][TestProperty(key, value)]
    Assert.Equal / NotEqualAssert.AreEqual / AreNotEqual
    Assert.True / FalseAssert.IsTrue / IsFalse
    Assert.Null / NotNullAssert.IsNull / IsNotNull

    Remove 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.

    Preserve existing class inheritance. Do not mechanically seal classes.

    4. Resolve semantic mappings

    Load the mapping cheatsheet for every high-risk construct found in Step 1. These rules are mandatory:

    • xUnit Assert.Throws<T> is exact-type and maps to MSTest Assert.ThrowsExactly<T>.
    • xUnit Assert.ThrowsAny<T> permits derived types and maps to MSTest Assert.Throws<T>.
    • xUnit Assert.IsType<T> is exact-type and maps to Assert.IsExactInstanceOfType<T>; Assert.IsAssignableFrom<T> maps to Assert.IsInstanceOfType<T>.
    • 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.
    • [Ignore] and [Timeout] are modifiers; keep [TestMethod] so the test is discovered.
    • [DataRow] values must exactly match parameter types.
    • TestContext.Current.CancellationToken maps to an injected MSTest TestContext.CancellationToken; never replace it with CancellationToken.None or a new CancellationTokenSource.
    • Owner is a reserved VSTest property. Map [Trait("Owner", value)] to [Owner(value)], not [TestProperty("Owner", value)].
    • 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.

    Apply 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.

    5. Preserve lifecycle, fixture scope, and parallelization

    • Keep constructor setup and IDisposable/IAsyncDisposable when valid. Map IAsyncLifetime to [TestInitialize]/[TestCleanup].
    • Map IClassFixture<T> to class-scoped initialization and cleanup.
    • For ICollectionFixture<T>, preserve both sharing and serialization. Prefer a static Lazy<T> 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.
    • Replace ITestOutputHelper with injected or property-based MSTest TestContext.

    xUnit runs classes in parallel by default; MSTest runs them serially. Unless the source disabled parallelism, preserve xUnit behavior with:

    [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)]
    

    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.

    6. Verify parity

    1. 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.
    2. Compare discovered, passed, failed, and skipped counts.
    3. Investigate every difference before declaring completion:
      • missing cases -> discovery attributes, DynamicData, or DataRow literal types
      • changed exception behavior -> exact-vs-derived assertion mapping
      • shared-state failures or large duration changes -> fixture scope and parallelization
      • silently skipped tests -> missing [TestMethod] or incorrect runtime-skip conversion
    4. Confirm no xUnit package, namespace, attribute, runner configuration, or fixture interface remains unless explicitly documented for manual follow-up.
    5. Read back any runner or parallelization configuration you changed and report its file path and effective setting.

    Completion Criteria

    • Current xUnit version and test platform were identified
    • xUnit packages and source constructs were converted
    • Target framework and test platform stayed unchanged
    • Fixture scope and parallelization decisions are explicit
    • Build succeeds
    • Test discovery and result counts match the baseline
    • Any unsupported custom extension point is called out rather than approximated

    Follow-up

    Run 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.

    Frequently asked questions

    What to verify before installation and use

    What does the migrate-xunit-to-mstest source document cover?

    Convert 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/fail results and execution semantics.

    How do I install migrate-xunit-to-mstest?

    The source record exposes this install command: npx skills add https://github.com/dotnet/skills --skill "plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest". Inspect the command and pinned source before running it.

    Which permission-related actions were detected?

    Static rules flagged exec-script, read-files in the source; the page lists the matching lines and excerpts.

    Alternatives

    Compare before choosing

    Computed 10029,236

    garrytan/gbrain

    bulk-ingestion

    End-to-end discipline for turning any large data source (audio libraries, email takeouts, document corpora, chat exports, API dumps) into brain pages at scale. The lifecycle spine: SCHEMA → ACCESS → TRIAL → EVALUATE → IMPROVE → CODIFY → TEST → SKILLIFY → BULK → MONITOR. State is tracked in a durable JSON manifest (see MANIFEST-PATTERN.md) so any crash, session boundary, or subagent fan-out resumes from ground truth instead of memory.

    Computed 10025,136

    alirezarezvani/claude-skills

    app-store-optimization

    App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist

    Computed 1005,277

    dotnet/skills

    migrate-vstest-to-mtp

    Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing

    Computed 991,260

    vipshop/cache-dit

    cache-dit-model-integration

    High-level guide for integrating a new DiT model into cache-dit: Cache (BlockAdapter/ForwardPattern), Context Parallelism, Tensor Parallelism, Text Encoder Parallelism (TE-P), VAE Parallelism (VAE-P), generate CLI, installation, testing workflow, and detailed references. Use when adding support for a new diffusion transformer model in cache-dit.