migrate-nunit-to-mstest
できること
このスキルは、.NETプロジェクトのNUnitテストを、テストの動作を変えずにMSTest v4へ変換します。チェックの内容を変えずに、テストフレームワークをMSTestに移したいチーム向けです。
使う場面
- ✓.NETのテストプロジェクトがNUnitを使っていて、MSTestに切り替えたいとき。
- ✓NUnitの属性、アサーション、セットアップメソッドを、MSTestの相当する機能に置き換えたいとき。
- ✓ファイルを編集する前に、NUnitのテストを変換する計画だけがほしいとき。
スキルのリンク
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-nunit-to-mstest/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のNUnitテストプロジェクトをMSTest v4に変換してください。同じテストが実行され、合格することも確認してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはNUnitのパッケージと属性を見つけ、MSTestの相当する機能に変換します。そのあとプロジェクトをビルドし、テストを実行して、同じ結果になることを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
NUnit -> MSTest Migration
Convert NUnit 3 or 4 tests to MSTest v4 without changing the target framework or test platform. A successful migration builds, discovers the same test cases, and preserves pass/fail, lifecycle, data, filtering, and concurrency semantics.
Scope
Use this skill only when the project contains NUnit packages or source and the user wants MSTest. If the project already uses MSTest and contains no NUnit 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
- Search the current working directory for projects and source; never look for user files under this skill's directory.
- Classify the deliverable: "convert this project" means edit, build, and test; "give me a plan" means answer without editing.
- Preserve the user's requested project scope. Shared props may be changed only when they own NUnit package or runner configuration for that scope.
- The final response must state the source NUnit version, preserved runner, changed files, high-risk semantic mappings, and actual test counts.
Response Mode
- Full migration request: inspect, edit, build, and run tests. Do not stop after a plan.
- Focused compile error or API question: apply only the relevant mapping.
- 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.
Decisions That Change the Result
| Detected state | Required action |
|---|---|
| No NUnit package, namespace, attribute, or constraint remains | Stop, make no changes, and run the existing test command once to prove the already-MSTest project is healthy. |
| Source uses VSTest | Preserve VSTest. Retain and update an explicit Microsoft.NET.Test.Sdk pin when the repository owns one; do not introduce MTP properties. |
| Source uses MTP | Replace NUnit-specific MTP configuration with MSTest MTP configuration. Prefer MSTest.Sdk; with the metapackage set EnableMSTestRunner=true and OutputType=Exe. |
| NUnit uses its default fixture lifecycle | NUnit normally shares one fixture instance across all test cases; MSTest creates a new class instance per test. Move state that must remain class-shared behind static fields initialized by [ClassInitialize], or prove the state is per-test before leaving it as an instance field. |
NUnit has no Parallelizable configuration |
Preserve serial execution. Do not add [assembly: Parallelize]; NUnit and MSTest are both serial by default. |
| NUnit explicitly enables parallel execution | Translate the effective scope and worker count. Never infer method-level parallelism from fixture-level settings. |
For detailed mappings, search references/mapping-cheatsheet.md for constructs present in the project and read only those sections.
Fast Path
For a routine migration, converge in four phases: one batched discovery pass, one edit pass, one dotnet test, and one concise result.
- Use an existing CI/test result as the baseline when available.
- Run a pre-edit baseline when counts are unavailable and the project contains parameterized tests, fixture state, namespace setup, retries, custom attributes, or explicit parallelization.
- Do not run separate restore, build, and test commands when
dotnet testis sufficient. - Do not delete NUnit runner configuration until its behavior has been translated.
Workflow
1. Establish the baseline
- Batch-read test projects, central package files,
global.json,.runsettings,testconfig.json, and NUnit configuration. - Detect NUnit from
NUnit,NUnit3TestAdapter,NUnit.Analyzers,NUnit.Framework,NUnit.Framework.Legacy, andusing NUnit.Framework. - State whether the source is NUnit 3 or 4 from the resolved package version.
- Detect VSTest or MTP and preserve it. Use
platform-detectiononly when ambiguous. - Record target frameworks and stop if MSTest v4 does not support them.
- Inventory high-risk constructs:
[TestFixture(...)],[TestFixtureSource],[FixtureLifeCycle], constructors with parameters[TestCase],[TestCaseSource],TestCaseData,[Values],[Range],[Random],[Sequential],[Pairwise], custom data attributes[Theory],[Datapoint], `[Dat
よくある質問
.NETのバージョンも上げますか?
いいえ。対象フレームワークの変更は別の手順で、この変換には含まれません。
同じテストが検出されますか?
それが目標です。変換の後も、同じテストケースが検出されることをスキルが確認します。
計画だけがほしい場合は?
スキルは、変更を加えずに計画を返すことができます。
詳細
作者による元の説明
Convert .NET tests from NUnit 3/4 to MSTest v4 while preserving VSTest or MTP. Use for replacing NUnit/NUnit3TestAdapter packages, Test/TestCase/ TestCaseSource/Values attributes, constraint assertions, SetUp/TearDown, OneTimeSetUp, SetUpFixture, FixtureLifeCycle, TestContext, categories, retries, timeouts, and NUnit parallelization. Also use when a "convert NUnit to MSTest" request may already be migrated: inspect and report the no-op. Do not use for NUnit version upgrades, xUnit/TUnit conversion, MSTest upgrades, or runner-only VSTest-to-MTP migration.
repo: dotnet/skills
人気
- GitHubのスター
- 5.8k
- ランキング
- #14619
- ライセンス
- 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ライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。