Agent skill · Databases

migrate-mstest-v3-to-v4

Fix build errors and breaking changes after upgrading MSTest v3 to v4, or plan a complete v3-to-v4 migration. Use when user says "upgrade to MSTest v4", "MSTest 4 migration", "MSTest v4 breaking changes", "tests don't compile after upgrading MSTest 3.x to 4.x", or hits CS0507, CS0103, CS1061, CS1615 after updating MSTest packages to 4.x. USE FOR: Execute to ExecuteAsync, CallerInfo ctor on TestMethodAttribute, sealed custom attributes, ClassCleanupBehavior removal, TestContext.Properties Contains to ContainsKey, Assert.ThrowsException to ThrowsExactly, Assert.IsInstanceOfType out param removal

dotnetgithub.com/dotnetGitHub ↗
claude-codeMIT
Install
npx skills add dotnet/skills --skill migrate-mstest-v3-to-v4 --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 23 KB
Bundled scripts: none
Path: plugins/dotnet-test-migration/skills/migrate-mstest-v3-to-v4/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 4,927
Language: C#
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Guides upgrading MSTest from v3 to v4 by enumerating concrete code changes and target framework considerations. It instructs how to adapt custom TestMethodAttribute usage, attribute constructors with CallerInfo, cleanup attributes, TestContext usage, timeout and managed context changes, and several Assert API updates. It also covers removing certain attributes and updating project targets, providing code samples for each breaking change.

How it works

  • Identify overrides of TestMethodAttribute.Execute and replace with ExecuteAsync returning Task<TestResult[]> (or implement async logic).
  • Update custom TestMethodAttribute constructors to propagate CallerFilePath and CallerLineNumber to the base class; switch [TestMethodAttribute("name")] to [TestMethodAttribute(DisplayName = "name")].
  • Remove ClassCleanupBehavior.EndOfClass usage; annotate with [ClassCleanup] and move EndOfAssembly cleanup to [AssemblyCleanup] if previously used.
  • Change TestContext.Properties usage from IDictionary to IDictionary<string, object> and update Contains("key") calls to ContainsKey("key").
  • Replace [Timeout(TestTimeout.Infinite)] with [Timeout(int.MaxValue)].
  • Replace TestContext.ManagedType with TestContext.FullyQualifiedTestClassName.
  • Update Assert API calls: use interop-friendly signatures and modern equivalents, e.g., interpolate messages instead of format strings; replace Assert.ThrowsException with Assert.ThrowsExactly or Assert.Throws; replace out-parameter usage for IsInstanceOfType with direct assignment.
  • Replace or relocate [ExpectedException] usages to Assert.ThrowsExactly or Assert.ThrowsAsync as appropriate.
  • Update TargetFrameworks to supported net8.0/net9.0 or equivalents per v4 requirements; drop unsupported TFMs.
  • Follow the Step-by-step workflow for assessing, updating, and resolving breaking changes.

When to use it

  • When upgrading MSTest.TestFramework, MSTest.TestAdapter, MSTest, or MSTest.Sdk from 3.x to 4.x.
  • When addressing build errors after upgrading to MSTest v4 packages.
  • When updating custom TestMethodAttribute or ConditionBaseAttribute implementations for v4.
  • When migrating from v3 to v4 in projects with specific breaking changes listed in the guide.

What it can touch

  • Code implementing custom TestMethodAttribute, including overrides of Execute/ExecuteAsync.
  • Constructors of TestMethodAttribute subclasses that rely on CallerFilePath/CallerLineNumber.
  • ClassCleanup attributes and related cleanup mechanisms.
  • Accesses to TestContext.Properties and affected usage patterns.
  • Timeout and TestTimeout usage in test methods.
  • TestContext.ManagedType and replacement with FullyQualifiedTestClassName.
  • Assert API calls, including AreEqual, ThrowsException, IsInstanceOfType, and ExpectedException usage.
  • Project file settings for TargetFrameworks (net8.0/net9.0 and related allowed TFMs).

Caveats

  • MSTest v4 is not binary compatible with v3; recompile libraries against v4.
  • Some changes require code restructuring (e.g., lambdas for ExpectedException removal).
  • Ensure target frameworks are supported by v4 before migrating.
From the SKILL.md

# MSTest v3 -> v4 Migration Migrate a test project from MSTest v3 to MSTest v4. The outcome is a project using MSTest v4 that builds cleanly, passes tests, and accounts for every source-incompatible and behavioral change. MSTest v4 is **not binary compatible** with MSTest v3 -- any library compiled against v3 must be recompiled against v4. ## When to Use - Upgrading `MSTest.TestFramework`, `MSTest.TestAdapter`, or `MSTest` metapackage from 3.x to 4.x - Upgrading `MSTest.Sdk` from 3.x to 4.x - Fixing build errors after updating to MSTest v4 packages - Resolving behavioral changes in test execution after upgrading to MSTest v4 - Updating custom `TestMethodAttribute` or `ConditionBaseAttribute` implementations for v4 ## When Not to Use - The project already uses MSTest v4 and builds cleanly -- migration is done - Upgrading from MSTest v1 or v2 -- use `migrate-mstest-v1v2-to-v3` first, then return here - The project does not use MSTest - Migrating between test frameworks (e.g., MSTest to xUnit or NUnit) ## Inputs | Input | Required | Description | |-------|----------|-------------| | Project or solution path | No | The `.csproj`, `.sln`, or `.slnx` entry point containing MSTest test pr

What's inside
Steps it walks through
  1. When to Use
  2. When Not to Use
  3. Inputs
  4. Response Guidelines
  5. Workflow
  6. Step 1: Assess the project
  7. Step 2: Update packages to MSTest v4
  8. Step 3: Resolve source breaking changes
  9. Step 4: Address behavioral changes
  10. Step 5: Verify
  11. Validation
  12. Related Skills
  13. Common Pitfalls
More from skills
All skills →
About this skill
What does the migrate-mstest-v3-to-v4 skill do?

Fix build errors and breaking changes after upgrading MSTest v3 to v4, or plan a complete v3-to-v4 migration. Use when user says "upgrade to MSTest v4", "MSTest 4 migration", "MSTest v4 breaking changes", "tests don't compile after upgrading MSTest 3.x to 4.x", or hits CS0507, CS0103, CS1061, CS1615 after updating MSTest packages to 4.x. USE FOR: Execute to ExecuteAsync, CallerInfo ctor on TestMethodAttribute, sealed custom attributes, ClassCleanupBehavior removal, TestContext.Properties Contains to ContainsKey, Assert.ThrowsException to ThrowsExactly, Assert.IsInstanceOfType out param removal

How do I install it?

Run `npx skills add dotnet/skills --skill migrate-mstest-v3-to-v4 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going