migrate-xunit-to-mstest

Migrate .NET test projects from xUnit v2 or v3 to MSTest v4.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill migrate-xunit-to-mstest-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-xunit-to-mstest
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/migrate-xunit-to-mstest
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill migrate-xunit-to-mstest-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Converting a .NET test suite from xUnit to MSTest by hand is error-prone: attribute names, assertion semantics, fixture scopes, and parallelization defaults all differ between the frameworks, and silent mistakes (like reversing Throws/ThrowsExactly or dropping parallel execution) regress tests without obvious errors. This Skill provides a step-by-step migration workflow with complete mapping tables so the converted project builds cleanly and preserves test behavior. ## Core Features & Use Cases - Package and project migration: Removes all xUnit/xunit.v3 package references and installs MSTest v4 via the MSTest metapackage or MSTest.Sdk, while preserving the existing test platform (VSTest or Microsoft.Testing.Platform). - Attribute, assertion, and data-driven test conversion: Maps [Fact]/[Theory]/[InlineData]/[MemberData] to [TestMethod]/[DataRow]/[DynamicData] and rewrites assertions, including the critical Assert.Throws exact-type vs derived-type semantic trap. - Fixture, lifecycle, and parallelization handling: Converts IClassFixture/ICollectionFixture to [ClassInitialize]/[AssemblyInitialize] patterns, ports ITestOutputHelper to TestContext, and restores xUnit's parallel-class default via [assembly: Parallelize(Scope = ClassLevel)]. - Use Case: A solution mixes xUnit and MSTest test projects and the team wants one framework. Run this Skill on the xUnit projects to convert packages, attributes, assertions, fixtures, and parallelization settings, committing at defined checkpoints so reviewers can bisect changes. ## Quick Start Migrate the xUnit test project at tests/MyApp.Tests.csproj to MSTest v4, preserving its current test platform and parallelization behavior.

Frequently Asked Questions about migrate-xunit-to-mstest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate xUnit tests to MSTest in .NET?

Replace all xunit package references with the MSTest 4.1.0 metapackage or MSTest.Sdk, convert [Fact]/[Theory] to [TestMethod], map assertions like Assert.Equal to Assert.AreEqual, and rewrite fixtures using [ClassInitialize]. Follow the stepwise workflow with commits after package, attribute, and fixture stages.

What is the MSTest equivalent of xUnit Assert.Throws?

xUnit Assert.Throws<T> requires an exact type match, so it maps to MSTest Assert.ThrowsExactly<T>. xUnit Assert.ThrowsAny<T>, which accepts derived types, maps to MSTest Assert.Throws<T>. Reversing these silently flips assertion semantics.

Does MSTest run tests in parallel like xUnit?

No. MSTest runs test classes serially by default, while xUnit parallelizes across classes. Add [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)] to match xUnit behavior, and use [DoNotParallelize] on classes that share state.

Can I convert xUnit ICollectionFixture to MSTest?

MSTest has no direct equivalent because xUnit collections both share a fixture and serialize execution. Use a static Lazy<T> helper with [ClassInitialize] for sharing plus [DoNotParallelize] for serialization, or [AssemblyInitialize] only when assembly-wide scope is acceptable.

Which target frameworks does MSTest v4 support?

MSTest v4 supports net8.0, net9.0, net462 and later, netstandard2.0 test libraries, uap10.0.16299, and specific Windows TFMs for WinUI and UWP. .NET Core 3.1 and net5.0 through net7.0 are unsupported and require a TFM upgrade first.

When should I not use the xUnit to MSTest migration?

Do not use it for xUnit v2 to v3 upgrades, MSTest version upgrades, VSTest-to-MTP platform switches, or NUnit/TUnit conversions. Those scenarios have dedicated skills or no existing skill, and combining them with a framework migration in one pass is discouraged.