Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

migrate-mstest-v1v2-to-v3将 mstest v1v2 迁移到 v3

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

4,064

周安装

166

GitHub Stars

1,476

下载量

1,315
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:migrate-mstest-v1v2-to-v3(将 mstest v1v2 迁移到 v3)
来源仓库:https://github.com/dotnet/skills
仓库路径:skills/migrate-mstest-v1v2-to-v3
安装命令:
npx skills add https://github.com/dotnet/skills --skill migrate-mstest-v1v2-to-v3
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dotnet/skills --skill migrate-mstest-v1v2-to-v3

简介

用于辅助测试设计、自动化测试、用例整理和回归验证,支持多宿主环境。

  • 适合编写单元测试、端到端测试或根据失败日志定位问题。
  • 需确认项目测试框架、运行命令和夹具数据,避免改坏真实逻辑。
  • 涉及浏览器或外部服务时应区分本地模拟、测试环境和生产环境。
  • migrate-mstest-v1v2-to-v3 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

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.

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
  • Replacing .testsettings with .runsettings
  • Adopting MSTest.Sdk or in-assembly parallel execution

When Not to Use

  • Project already uses MSTest v3 (3.x packages)
  • Upgrading v3 to v4 -- use migrate-mstest-v3-to-v4
  • Migrating between frameworks (MSTest to xUnit/NUnit)

Inputs

InputRequiredDescription
Project or solution pathYesThe .csproj, .sln, or .slnx entry point containing MSTest test projects
Build commandNoHow to build (e.g., dotnet build, a repo build script). Auto-detect if not provided
Test commandNoHow to run tests (e.g., dotnet test). Auto-detect if not provided

Breaking Changes Summary

MSTest v3 introduces these breaking changes from v1/v2. Address only the ones relevant to the project:

Breaking ChangeImpactFix
Assert.AreEqual(object, object) overload removedCompile error on untyped assertionsAdd generic type: Assert.AreEqual<T>(expected, actual). Same for AreNotEqual, AreSame, AreNotSame
DataRow strict type matchingRuntime/compile errors when argument types don't match parameter types exactlyChange literals to exact types: 1 for int, 1L for long, 1.0f for float
DataRow max 16 constructor parameters (early v3)Compile error if >16 args; fixed in later v3 versionsUpdate to latest 3.x, or refactor test / wrap extra params in array
.testsettings / <LegacySettings> no longer supportedSettings silently ignoredDelete .testsettings, create .runsettings with equivalent config
Timeout behavior unified across.NET Core / FrameworkTests with [Timeout] may behave differentlyVerify timeout values; adjust if needed
Dropped target frameworks:.NET 5,.NET Fx < 4.6.2, netstandard1.0, UWP < 16299, WinUI < 18362Build errorUpdate TFM:.NET 5 -> net8.0 (LTS) or net6.0+, netfx -> net462+, netstandard1.0 -> netstandard2.0. Note: net6.0, net8.0, net9.0 are all supported
Not binary compatible with v1/v2Libraries compiled against v1/v2 must be recompiledRecompile all dependencies against v3

Response Guidelines

  • Always identify the current version first: Before recommending any migration steps, explicitly state the current MSTest version detected in the project (e.g., "Your project uses MSTest v2 (2.2.10)" or "This is an MSTest v1 project using QualityTools assembly references"). This grounds the migration advice and confirms you've read the project files.
  • Focused fix requests (user has specific compilation errors after upgrading): Address only the relevant breaking change from the table above. Show a concise before/after fix. Do not walk through the full migration workflow.
  • Specific feature migration (user asks about one aspect like.testsettings, DataRow, or assertions): Address only that specific aspect with a concrete fix. Do not walk through the entire migration workflow or unrelated breaking changes.
  • "What to expect" questions (user asks about breaking changes before upgrading): Present only the breaking changes that are clearly relevant to the user's visible code and configuration. For each, give a one-line fix summary. Do not include every possible breaking change -- only the ones that apply. Do not walk through the full workflow.
  • Full migration requests (user wants complete migration): Follow the complete workflow below.
  • Comparison questions (user asks about v1 vs v2 differences): Explain concisely -- v1 uses assembly references and requires removing them first; v2 uses NuGet and just needs a version bump. Both converge on the same v3 packages and breaking changes.

Migration Paths

  • MSTest v1 (assembly reference to QualityTools): Remove the assembly reference (Step 2), add v3 NuGet packages (Step 3), fix breaking changes (Step 5).
  • MSTest v2 (NuGet packages 1.x-2.x): Update package versions to 3.x (Step 3), fix breaking changes (Step 5). No assembly reference removal needed.

Both paths converge at Step 3 -- the same v3 packages and breaking changes apply regardless of starting version.

Workflow

Step 1: Assess the project

  1. Identify which MSTest version is currently in use:

- Assembly reference: Look for Microsoft.VisualStudio.QualityTools.UnitTestFramework in project references -> MSTest v1 - NuGet packages: Check MSTest.TestFramework and MSTest.TestAdapter package versions -> v1 if 1.x, v2 if 2.x

  1. Check if the project uses a .testsettings file (indicated by <LegacySettings> in test configuration)
  2. Check if the target framework is dropped in v3 (see Step 4)
  3. Run a clean build to establish a baseline of existing errors/warnings

Step 2: Remove v1 assembly references (if applicable)

If the project uses MSTest v1 via assembly references:

  1. Remove the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

- In SDK-style projects, remove the <Reference> element from the .csproj - In non-SDK-style projects, remove via Visual Studio Solution Explorer -> References -> right-click -> Remove

  1. Save the project file

Step 3: Update packages to MSTest v3

Choose one of these approaches:

Option A -- Install the MSTest metapackage (recommended):

Remove individual MSTest.TestFramework and MSTest.TestAdapter package references and replace with the unified MSTest metapackage:

<PackageReference Include="MSTest" Version="3.8.0" />

Also ensure Microsoft.NET.Test.Sdk is referenced (or update individual MSTest.TestFramework + MSTest.TestAdapter packages to 3.8.0 if you prefer not using the metapackage).

Option B -- Use MSTest.Sdk (SDK-style projects only):

Change <Project Sdk="Microsoft.NET.Sdk"> to <Project Sdk="MSTest.Sdk/3.8.0">. MSTest.Sdk automatically provides MSTest.TestFramework, MSTest.TestAdapter, MSTest.Analyzers, and Microsoft.NET.Test.Sdk.

Important: MSTest.Sdk defaults to Microsoft.Testing.Platform (MTP) instead of VSTest. For VSTest compatibility (e.g., vstest.console in CI), add <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />.

When switching to MSTest.Sdk, remove these (SDK provides them automatically):

  • Packages: MSTest, MSTest.TestFramework, MSTest.TestAdapter, MSTest.Analyzers, Microsoft.NET.Test.Sdk
  • Properties: <EnableMSTestRunner>, <OutputType>Exe</OutputType>, <IsPackable>false</IsPackable>, <IsTestProject>true</IsTestProject>

Step 4: Update target frameworks if needed

MSTest v3 supports.NET 6+,.NET Core 3.1,.NET Framework 4.6.2+,.NET Standard 2.0, UWP 16299+, and WinUI 18362+. If the project targets a dropped framework version, update to a supported one:

DroppedRecommended replacement
.NET 5.NET 8.0 (current LTS) or.NET 6+
.NET Framework < 4.6.2.NET Framework 4.6.2
.NET Standard 1.0.NET Standard 2.0
UWP < 16299UWP 16299
WinUI < 18362WinUI 18362
Note:.NET 6,.NET 8, and.NET 9 are all supported by MSTest v3. Do not change TFMs that are already supported.

Step 5: Resolve build errors and breaking changes

Run dotnet build and fix errors using the Breaking Changes Summary above. Key fixes:

Assertion overloads -- MSTest v3 removed Assert.AreEqual(object, object) and Assert.AreNotEqual(object, object). Add explicit generic type parameters:

// Before (v1/v2)                           // After (v3)
Assert.AreEqual(expected, actual);        -> Assert.AreEqual<MyType>(expected, actual);
Assert.AreNotEqual(a, b);                -> Assert.AreNotEqual<MyType>(a, b);
Assert.AreSame(expected, actual);         -> Assert.AreSame<MyType>(expected, actual);

DataRow strict type matching -- argument types must exactly match parameter types. Implicit conversions that worked in v2 fail in v3:

// Error: 1L (long) won't convert to int parameter -> fix: use 1 (int)
// Error: 1.0 (double) won't convert to float parameter -> fix: use 1.0f (float)

Timeout behavior -- unified across.NET Core and.NET Framework. Verify [Timeout] values still work.

Step 6: Replace.testsettings with.runsettings

The .testsettings file and <LegacySettings> are no longer supported in MSTest v3. Delete the .testsettings file and create a .runsettings file -- do not keep both.

Key mappings:

.testsettings.runsettings equivalent
TestTimeout property<MSTest><TestTimeout>30000</TestTimeout></MSTest>
Deployment config<MSTest><DeploymentEnabled>true</DeploymentEnabled></MSTest> or remove
Assembly resolution settingsRemove -- not needed in modern.NET
Data collectors<DataCollectionRunSettings><DataCollectors> section
Important: Map timeout to <MSTest><TestTimeout> (per-test), not <TestSessionTimeout> (session-wide). Remove <LegacySettings> entirely.

Step 7: Verify

  1. Run dotnet build -- confirm zero errors and review any new warnings
  2. Run dotnet test -- confirm all tests pass
  3. Compare test results (pass/fail counts) to the pre-migration baseline
  4. Check that no tests were silently dropped due to discovery changes

Validation

  • MSTest v3 packages (or MSTest.Sdk) correctly referenced; v1/v2 references removed
  • Project builds with zero errors
  • All tests pass (dotnet test) -- compare pass/fail counts to pre-migration baseline
  • .testsettings replaced with .runsettings (if applicable)

Next Step

After v3 migration, use migrate-mstest-v3-to-v4 for MSTest v4.

Common Pitfalls

PitfallSolution
Missing Microsoft.NET.Test.SdkAdd package reference -- required for test discovery with VSTest
MSTest.Sdk tests not found by vstest.consoleMSTest.Sdk defaults to Microsoft.Testing.Platform; add explicit Microsoft.NET.Test.Sdk for VSTest compatibility

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.42%
按下载量换算492

Claude

27.39%
按下载量换算360

Cursor

19.07%
按下载量换算251

Gemini CLI

9.08%
按下载量换算119

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills