mtp-hot-reload
できること
このスキルは、Microsoft Testing Platformのプロジェクトで、長時間動くテストホストを設定して実行します。最初からやり直さずに、コードの編集後にテストを再実行します。コードを何度も編集し、失敗したテストを再実行する開発者向けです。
使う場面
- ✓Microsoft Testing Platformのプロジェクトで、編集を保存するたびにテストを自動で再実行したいとき。
- ✓失敗しているテストを修正しながら、素早く編集と再実行を繰り返したいとき。
- ✓Microsoft Testing Platformを使うテストプロジェクトに、ホットリロードを設定したいとき。
スキルのリンク
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/mtp-hot-reload/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“失敗しているテストが、変更を保存するたびに再実行されるようにテストプロジェクトを設定してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはテストプラットフォームを確認し、ホットリロードのためにコンソールホストを設定します。そして、編集中もホストが動き続けるコマンドを案内します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
MTP Hot Reload for Iterative Test Fixing
Set up and use a long-lived Microsoft Testing Platform host that applies code edits and automatically reruns tests.
When to Use
- User explicitly asks for test hot reload
- User wants a host to stay running and automatically rerun after repeated edits
- User needs to set up MTP hot reload in their project
When Not to Use
- User needs to write new tests from scratch (use general coding assistance)
- User needs to diagnose why a test is failing (use diagnostic skills)
- User asks about Visual Studio or VS Code Test Explorer hot reload or an IDE-integrated rerun experience (different feature, not MTP console-host hot reload)
- User asks whether the editor can auto-rerun affected tests after source edits without using an MTP console host
- User wants one normal run without rebuilding (use
run-tests) - User needs CI/CD pipeline configuration
Inputs
| Input | Required | Description |
|---|---|---|
| Test project path | No | Path to the test project (.csproj). Defaults to current directory. |
| Failing test name or filter | No | Specific test(s) to iterate on |
Response sizing
- If setup is already complete and the user asks only which command to use,
return one
dotnet run --project <path>command and one sentence explaining that it starts the persistent host. Do not repeat package, launch profile, or rude-edit guidance. - If the package is already installed, show only the remaining enable-and-run steps. Do not suggest reinstalling it or add optional persistence/recovery paths unless requested.
- For a named test, identify the framework and return one runnable command with
that framework's filter syntax. Never substitute MSTest/NUnit
--filterfor xUnit v3--filter-methodor TUnit--treenode-filter. - A directly launched MTP host is itself the persistent watcher:
dotnet runstays alive and the HotReload extension reacts to edits. Do not replace it withdotnet watch runfor the normal MTP path; reservedotnet watchfor the explicit restart fallback below.
Workflow
Step 1: Detect the platform before changing anything
Hot reload requires MTP. It does not work with VSTest.
Follow the complete evaluated-property procedure in the platform-detection
skill. Read imported props and package versions as well as the project file.
Do this before installing packages, editing files, or returning an MTP launch
command.
Hard stop for VSTest: report that MTP hot reload is unavailable for the
project as configured and stop the MTP setup path. Do not install the extension,
create launchSettings.json, set the environment variable, change runner
properties/packages, or return a dotnet run hot-reload command. Never turn a
setup request into an implicit VSTest-to-MTP migration.
Offer one valid non-MTP fallback that preserves the project:
dotnet watch --project <project-path> test
This rebuilds and reruns the existing VSTest project when files change; it is
not MTP hot reload. Offer an explicit migration as a separate option, but do not
perform it unless the user asks. Exact one-shot test commands remain owned by
run-tests.
Step 2: Add the hot reload NuGet package
First inspect the effective package references. If
Microsoft.Testing.Extensions.HotReload is already installed, preserve its
version and skip this step. Otherwise install it:
dotnet add <project-path> package Microsoft.Testing.Extensions.HotReload
Note: When using
Microsoft.Testing.Platform.MSBuild(included transitively by MSTest, NUnit, and xUnit runners), the extension is auto-registered when you install its NuGet package -- no code changes needed.
Step 3: Enable hot reload
Hot reload is activated by setting the TESTINGPLATFORM_HOTRELOAD_ENABLED environment variable to 1.
Option A -- Set it in the shell before running tests:
# PowerShell
$env:TESTINGPLATFORM_HOTRELOAD_ENABLED = "1"
# bash/zsh
export TESTINGPLATFORM_HOTRELOAD_ENABLED=1
Option B -- Add it to launchSettings.json (recommended for repeatable use):
Create or update Properties/launchSettings.json in the test project:
{
"profiles": {
"<ProjectName>": {
"commandName": "Project",
"environmentVariables": {
"TESTINGPLATFORM_HOTRELOAD_ENABLED": "1"
}
}
}
}
Step 4: Run the tests with hot reload
Run the test project directly (not through `dotnet t
よくある質問
Visual Studioのテストエクスプローラーでも動きますか?
いいえ。このスキルはコンソールホストの方法を扱います。IDEのテストエクスプローラーのホットリロードは、別の機能です。
再実行するテストを絞れますか?
はい。フィルターも扱うので、ループを特定のテストに絞れます。
プロジェクトがVSTestを使っている場合は?
ホットリロードに対応していない場合は、プロジェクトを変えずに済む代替の方法を説明します。
詳細
作者による元の説明
Set up or recover MTP hot reload for a long-lived console-host edit/re-run loop in a Microsoft Testing Platform project. Use for explicit MTP console requests such as "enable hot reload", "dotnet run to rerun on edit", or unsupported/rude edits. Covers setup, run/watch, restarts, filters, and the VSTest no-mutation fallback. For one-time runs, exact commands, filter errors, TRX/dumps, or merely a failing test, use run-tests. Do not use when Test Explorer or an IDE should rerun tests without an MTP console host. Excludes editor integration, CI, and writing/debugging tests.
repo: dotnet/skills
人気
- GitHubのスター
- 5.8k
- ランキング
- #14633
- ライセンス
- 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ライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。