migrate-mstest-v3-to-v4

Migrates .NET test projects from MSTest v3 to v4 by fixing breaking changes.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Upgrading MSTest packages from 3.x to 4.x breaks builds with errors like CS0507, CS0103, and CS1061, and introduces silent behavioral changes such as lost test discovery and altered TestCase.Id generation. This Skill diagnoses those errors and walks through every source-incompatible and behavioral change until the project builds cleanly and all tests pass. ## Core Features & Use Cases - Breaking change resolution: Maps compiler errors to concrete fixes, including Execute to ExecuteAsync, CallerInfo constructors on TestMethodAttribute, ClassCleanupBehavior removal, TestContext.Properties ContainsKey, and Assert.ThrowsException to ThrowsExactly. - Behavioral change guidance: Addresses TestCase.Id regeneration, TreatDiscoveryWarningsAsErrors defaults, AppDomain changes, and MSTest.Sdk MTP mode versus vstest.console compatibility. - Use Case: After bumping MSTest.TestFramework to 4.1.0, your build fails on a custom TestMethodAttribute subclass and [ExpectedException] usages. The Skill identifies each error, provides copy-pasteable fixed code, and verifies the migration with dotnet build and dotnet test. ## Quick Start Migrate my test project to MSTest v4 and fix all the build errors that appeared after updating the packages.

Frequently Asked Questions about migrate-mstest-v3-to-v4

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

FAQPage Schema
How do I migrate from MSTest v3 to v4?

Update MSTest packages to 4.x, run dotnet build to collect errors, then fix each breaking change: replace Execute with ExecuteAsync, ExpectedException with Assert.ThrowsExactly, and ClassCleanupBehavior with plain [ClassCleanup]. Finish by running dotnet test to verify all tests pass.

How to fix ExpectedException attribute not found in MSTest v4?

ExpectedExceptionAttribute was removed in MSTest v4. Move the exception assertion into the test body using Assert.ThrowsExactly<T>(() => ...) for synchronous code or Assert.ThrowsExactlyAsync<T> for async tests, wrapping only the throwing call.

Why does vstest.console find no tests after upgrading MSTest.Sdk?

MSTest.Sdk defaults to Microsoft.Testing.Platform mode, which does not include Microsoft.NET.Test.Sdk that vstest.console requires. Either set UseVSTest to true in the project file or switch your CI pipeline to dotnet test.

Which target frameworks does MSTest v4 support?

MSTest v4 supports net8.0, net9.0, net462 (.NET Framework 4.6.2+), uap10.0.16299, modern UWP, and WinUI targets. Projects targeting net5.0, net6.0, net7.0, or netcoreapp3.1 must retarget to net8.0 or later.

When should I not use this MSTest v4 migration approach?

Do not use it when migrating from MSTest v1 or v2, which requires the migrate-mstest-v1v2-to-v3 skill first, or when switching between test frameworks like MSTest to xUnit or NUnit. It also does not apply to projects already building cleanly on v4.