migrate-xunit-to-mstest
できること
このスキルは、.NETプロジェクトのxUnit.netテストを、テストの確認内容を変えずにMSTest v4に変換します。xUnitからMSTestに移り、同じ動作を保ちたいチーム向けです。
使う場面
- ✓.NETのテストプロジェクトがxUnitを使っていて、MSTestに移したいとき。
- ✓xUnitの属性、フィクスチャ、アサーションを、MSTestの相当する機能に置き換えたいとき。
- ✓xUnitからMSTestへの変換依頼が、一部すでに終わっている可能性があり、確認が必要なとき。
スキルのリンク
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のxUnitテストをMSTest v4に変換し、同じ結果で通ることを確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはxUnitのパッケージと属性を見つけ、MSTestの相当する機能に変換します。そのあとプロジェクトをビルドし、テストを実行して、同じ結果になることを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
xUnit -> MSTest Migration
Convert xUnit.net v2 or v3 tests to MSTest v4 without changing the target framework or test platform. A successful migration builds, discovers the same tests, and preserves pass/fail results and execution semantics.
Scope
Use this skill only when the project contains xUnit packages or source and the user wants MSTest. If the project already uses MSTest and contains no xUnit tests, report that no framework migration is needed and make no changes.
Do not combine this framework conversion with a target-framework upgrade or VSTest/MTP migration. Complete and verify one migration before starting another.
Workspace Contract
- Continue after skill activation. Search the current working directory for the staged project and source; never look for user files under this skill's base directory.
- Open the literal paths returned by glob/search. If one reader or patch tool rejects a path that was just found, retry with another available tool. Do not ask the user for a path until current-workspace discovery is exhausted.
- Classify by the requested deliverable: "convert this project" means edit, build, and test; "give me a plan" or "how would I convert it?" means answer. Do not replace execution with "please provide the files" when files are present.
- The final response must state the source xUnit version, preserved runner, changed files, each high-risk semantic mapping applied, and actual test counts. Assertions about fixture lifetime, Owner mapping, cancellation, or parallelization must be visible in the resulting source, not only prose.
Response Mode
- Full migration request: inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.
- Focused compile error or API question: inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.
- Unsupported target framework: stop before changing packages. MSTest v4 requires .NET 8+ or .NET Framework 4.6.2+ for test applications; offer a separately approved TFM upgrade or MSTest v3 as the intermediate target.
Decisions That Change the Result
Apply these before the mechanical mapping:
| Detected state | Required action |
|---|---|
| No xUnit package, namespace, attribute, or fixture remains | Stop. Make no file changes, report that migration is unnecessary, and run the existing dotnet test command once to prove the already-MSTest project is healthy. |
| Source uses VSTest | Keep the existing VSTest property/configuration. Prefer retaining and updating a source project's explicit Microsoft.NET.Test.Sdk pin; a repository that intentionally relies on the MSTest metapackage's transitive dependency may keep that convention. Do not introduce MTP properties. |
| Source uses MTP | Replace xUnit-specific MTP selection with MSTest MTP configuration. Prefer MSTest.Sdk; with the metapackage, set EnableMSTestRunner=true and OutputType=Exe. Preserve native-versus-bridged command integration, and do not add <UseVSTest>true</UseVSTest> or other VSTest-only configuration. |
| Source relies on xUnit's default parallelization | Add [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)] to a compiled .cs file when the current project has at least two independently runnable test classes. In a one-class project with no explicit parallel setting, omit it because class-level concurrency is not observable. Translate explicit CollectionBehavior or xunit.runner.json settings regardless of current class count. Before reporting completion, read the changed file back and name it in the result. |
For detailed mappings and examples, search references/mapping-cheatsheet.md for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.
Fast Path
For a routine project migration, converge in four phases: one batched discovery read/search, one edit pass, one dotnet test, and one concise result. Do not:
- list a directory and then reread the same files through another tool
- copy project files into the loaded skill or its
references/directory; those files are read-only guidance, not an editing workspace - try
dotnet test --no-restoreunless restore is already known to be current - run separate restore, build, and test commands when
dotnet testis sufficient - rerun a passing test command or inspect unchanged files for confirmation
よくある質問
.NETの対象フレームワークも上げますか?
いいえ。対象フレームワークの変更は、フレームワークの切り替えとは別に扱います。
同じテストランナーを使い続けますか?
はい。プロジェクトが既に使っているランナーを維持します。
計画だけがほしい場合は?
頼まれた場合は計画を返し、変更は加えません。
詳細
作者による元の説明
Convert .NET tests from xUnit.net v2/v3 to MSTest v4 while preserving VSTest or MTP. Use for replacing xunit packages, Fact/Theory/InlineData/MemberData, assertions, IClassFixture/ICollectionFixture, ITestOutputHelper, TestContext cancellation, traits/Owner, skips, timeouts, and xUnit parallelization. Also use when a "convert xUnit to MSTest" request may already be migrated: inspect and report the no-op. Do not use for xUnit v2-to-v3, MSTest upgrades, NUnit/TUnit conversion, or runner-only VSTest-to-MTP migration.
repo: dotnet/skills
人気
- GitHubのスター
- 5.8k
- ランキング
- #14621
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
create-custom-agent
5.8kVisual Studio Codeのカスタムエージェントのファイルを、独自のツール、指示、ほかのエージェントへの引き継ぎとともに作るようエージェントを支援します。
create-skill
5.8k有効な名前、明確な発動の説明、規格に従うSKILL.mdファイルを持つ、新しいエージェントのスキルを作るようエージェントを支援します。
csharp-scripts
5.8k.NETのコマンドラインツールを使って、完全なプロジェクトを作らずに、小さなC#のプログラムを一つのファイルとして実行するようエージェントを支援します。
dotnet-pinvoke
5.8k署名、文字列の扱い、メモリ、安全なハンドルを含めて、ネイティブのC言語またはC++のライブラリを.NETから正しく呼び出すようエージェントを支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。