跳到正文
Skillpedia
测试5.8k · #14617

migrate-mstest-v1v2-to-v3

它能做什么

这项技能把 .NET 测试项目从较旧的 MSTest 版本(1 或 2)升级到 MSTest v3。适合测试项目在包升级之后出现故障或行为不同的团队。

适用场景

  • ✓当测试项目仍然引用来自 MSTest v1 的旧 QualityTools 程序集时。
  • ✓当项目使用 MSTest v1 或 v2 的 NuGet 包,并应迁移到 v3 时。
  • ✓当把 MSTest 包更新到 v3 后出现构建错误或 DataRow 类型不匹配的时候。

技能链接

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-mstest-v1v2-to-v3/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-mstest-v1v2-to-v3/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的测试项目使用的是 MSTest v2,我想升级到 MSTest v3。请修复所有出现故障的地方。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先检查包版本和项目的当前状态,然后应用源代码改动,并运行测试以确认升级有效。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

MSTest v1/v2 -> v3 Migration

Migrate a test project from MSTest v1 (assembly references) or MSTest v2 (NuGet 1.x-2.x) to MSTest v3. MSTest v3 is not binary compatible with v1/v2 -- libraries compiled against v1/v2 must be recompiled.

First Action

Inspect the supplied workspace and classify v1, v2, partially migrated v3, or already-complete v3 before answering. Do not search the web or answer from memory first. For an edit request, continue through the requested source changes and validation; for an advice request, answer directly after the classification.

When to Use

  • Project references Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll (MSTest v1)
  • Project uses MSTest.TestFramework / MSTest.TestAdapter NuGet 1.x or 2.x
  • Resolving build errors after updating MSTest packages from v1/v2 to v3 -- including when the packages already read 3.x and only the source or settings still need fixing
  • Replacing .testsettings with .runsettings
  • Adopting MSTest.Sdk or in-assembly parallel execution

When Not to Use

  • Project already on MSTest v3 with no migration-related build errors and no leftover .testsettings / <LegacySettings> (fully migrated)
  • Upgrading v3 to v4 -- use migrate-mstest-v3-to-v4
  • Migrating between frameworks (MSTest to xUnit/NUnit)

Boundary Gate

Check package versions before any edit. If all MSTest references are already 3.x, no v1/v2-to-v3 error is reported, and no .testsettings or <LegacySettings> remains, state that migration is complete and make no changes. A 3.x package version alone does not end the migration -- leftover v1/v2-era settings files or breaking-change errors are still in scope. Do not consolidate working v3 packages into the metapackage. Run the existing tests only if verification was requested. This overrides all steps below.

Inputs

Input Required Description
Project or solution path No The .csproj, .sln, or .slnx entry point. Glob the working directory for it; ask only if nothing is found or several test projects make the target ambiguous
Build command No How to build (e.g., dotnet build, a repo build script). Auto-detect if not provided
Test command No How to run tests (e.g., dotnet test). Auto-detect if not provided

Never open by asking for the project path. A user describing their project in prose is asking a question, not withholding a file -- look on disk first. If there is genuinely no project file, answer for the setup they described rather than replying with only a question.

Open the paths exactly as the search returned them. A glob that answers ./TestProject.csproj means the file is there, relative to the working directory -- read it at that path. Do not rebuild it into an absolute path under this skill's own base directory: that directory holds SKILL.md, not the user's project, so the read fails and the project looks missing when it is not. If a file you just found fails to open, the path you constructed is wrong -- retry with the literal result. Never conclude "there is no project on disk" while a search is still reporting project files, and never scaffold a substitute project from the prose description as a workaround.

Execution Contract

  • Skill activation is not a stopping point. Continue with workspace discovery and the requested work in the same task.
  • The skill directory contains guidance, not the staged project. Search the current working directory, open the literal paths returned by the search, and retry with another available reader/editor if one tool rejects a valid path.
  • Never ask for a path while a glob or directory search can discover it. Ask only after an exhaustive current-workspace search finds no project, or multiple projects make the target genuinely ambiguous.
  • Classify the requested deliverable, not isolated verbs: "make the edits", "update this project", or "then build and run" means execute; "what do I need to change?", "what should I expect?", "are the steps the same?", or "show me" means answer, even if the prompt also says upgrade or migrate.
  • After changing files, name the detected MSTest version and runner, every file changed, and the exact repaired calls/settings (for example, list each assertion changed to AreEqual<object>, AreNotEqual<object>, or AreSame<object>). Report the clean test counts. Do not claim VSTest preservation, a build, or passing tests witho
常见问题

MSTest v3 与 v1 或 v2 的库兼容吗?

不兼容。针对 v1 或 v2 构建的库必须重新编译,才能与 v3 一起使用。

它会改动已经在 v3 上的项目吗?

只有当项目仍残留迁移问题,例如旧的设置文件时才会。

它会把测试转换为其他框架吗?

不会。在 xUnit 或 NUnit 等框架之间迁移不在本技能范围之内。

详情

作者的原始描述

Use this skill before answering or editing whenever an MSTest v1/v2 project is being upgraded or repaired for v3. Triggers include QualityTools assembly references; MSTest.TestFramework/TestAdapter 1.x-2.x; "upgrade to MSTest v3"; comparing v1 and v2 migration paths; choosing MSTest or MSTest.Sdk; CS0411/CS1503 after a v3 package bump; DataRow type mismatch, MSTEST0014, or "Test data doesn't match method parameters"; .testsettings/LegacySettings to .runsettings; timeout changes; and net5.0 or other dropped v3 TFMs. Still use it when packages say 3.x but migration source errors or legacy settin

repo: dotnet/skills

热度

GitHub 星标
5.8k
排名
#14617
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能