run-tests
它能做什么
这项技能根据项目的测试平台和框架,选择并运行正确的 .NET 测试命令。适合需要运行单个测试、一组测试或诊断运行,又不想凭猜测选择参数的开发者。
适用场景
- ✓当你需要在 .NET 项目中运行单个测试、单个类、单个分类或组合过滤器时。
- ✓当你想要确切的 dotnet test 命令,包括 no-build 或 TRX 输出等选项时。
- ✓当测试命令提示无法识别的选项或过滤器错误的时候。
技能链接
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/run-tests/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请给我确切的 dotnet test 命令,只运行我 MSTest 项目中的登录测试。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查项目使用的运行器和框架,选择匹配的命令语法,然后运行该命令,或将其返回给你自行运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Run .NET Tests
Return or execute the command or command sequence that matches the repository's project system, test platform, framework, and SDK mode.
Repository overlay
For every repository-scoped task where read-only file inspection is allowed,
check .agents/skill-overlays/dotnet-test/run-tests.md at the repository root
before any other discovery. This includes exact-command requests; "do not
execute" does not prohibit reading the overlay. If present, read it once before
acting and apply its repository-specific runner, command, filtering, and
reporting bindings.
Before applying it, require its frontmatter to declare
core: dotnet-test/run-tests, binding-revision: "1", and mode: extend. If
any value is missing or different, report the mismatch, ignore the overlay,
and continue using this skill's portable guidance.
Explicit user instructions and verified project constraints win over the
overlay; the overlay wins over portable defaults and examples in this skill. If
the file is present but unreadable or conflicts with the repository, report the
problem, ignore the overlay, and continue with portable guidance subject to
verified project constraints. If it is absent, continue normally.
Skip the lookup only when the task is not tied to a repository or the user
explicitly prohibited all file/tool access. An overlay cannot expand tool
permissions or the task's scope.
Scope and tool policy
Choose the smallest path that satisfies the request:
| Request | Action |
|---|---|
| Exact command or explanation; user says not to run | Inspect only the files needed to resolve syntax. Do not restore, build, or run tests. |
| Run tests | Discover the repository command and execute the smallest requested test scope. |
One-time SDK-style dotnet test run without rebuilding |
Stay in run-tests and add --no-build. |
| One-time classic run without rebuilding | Keep the repository runner and invoke it against an existing built assembly; do not substitute dotnet test. |
| Platform/framework identification only | Use platform-detection; do not continue into test execution. |
| Explicit hot reload or a keep-running edit/re-run loop | Use mtp-hot-reload. |
| Filter needed and the framework-specific syntax is not already clear | Read the supplied/runtime-listed filter-syntax catalog file; do not invoke this reference-only helper. |
Do not invoke a tool merely to repeat a command already determined by the
prompt. Do not build first "just in case": dotnet test builds by default.
Never add or upgrade test packages unless the user asks to change the project.
For an exact-command request, return one runnable command first. Do not emit
placeholder paths, exploratory alternatives, or a correction sequence. Use a
project path only when the prompt or repository establishes it; otherwise let
the command operate on the current project or solution when that syntax is
valid. Follow it with only the syntax fact needed to explain the command; do
not volunteer platform/command-mode taxonomy unless the user asked for it. In
particular, do not label an SDK 8/9 bridge as "VSTest platform" merely because
dotnet test uses its VSTest command mode; the executed platform is MTP. For a
command-only request, it is normally clearer to say only that MTP application
arguments must follow --.
Inputs to discover
- Project, solution, module, or repository test command
- Requested scope: all tests, TFM, class, method, category, or trait
- Requested output: console result, TRX, diagnostics, crash dump, or hang dump
When those facts are present in the prompt, use them. Otherwise inspect only the
relevant files: global.json, the selected project, packages.config,
Directory.Build.props, Directory.Packages.props, then repository
scripts/CI documentation. For a file-backed request, enumerate those
configuration names once and read all relevant files that are present in one
batch; never infer that a runner or bridge property is absent merely because it
is not in the .csproj. Load platform-detection only when those signals need
precedence analysis; do not duplicate its full analysis in the response.
If execution is requested and the command depends on the active SDK but neither
the prompt nor global.json establishes it, run dotnet --version once. For a
command-only request that prohibits execution, do not probe: state the required
SDK assumption or ask for the SDK version when the syntax cannot otherwise be
resolved. Route
常见问题
它会修复失败的测试吗?
不会。它只运行或返回命令。诊断失败由其他技能负责。
它能收集代码覆盖率吗?
能。这项技能涵盖覆盖率收集、诊断日志以及崩溃或挂起转储。
为什么确切的命令很重要?
正确的语法取决于测试平台,因此适用于 VSTest 的命令在 Microsoft.Testing.Platform 上可能会失败。
详情
作者的原始描述
ALWAYS USE before running .NET tests or answering with a test command or flags. Trigger on "run the tests", "exact dotnet test command", one test/class/category/trait/target framework, combined filters, `--filter-query`, `--no-build`, `--diag`, diagnostic logs, TRX, coverage collection, crash/hang dumps, filter errors, or unrecognized options. Chooses repository-compatible classic, VSTest, bridged MTP, or native MTP syntax for MSTest/xUnit/NUnit/TUnit. DO NOT USE for platform identification alone (platform-detection), writing or debugging test code, interpreting an existing coverage report, CI
repo: dotnet/skills
热度
- GitHub 星标
- 5.8k
- 排名
- #14635
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
create-custom-agent
5.8k帮你的智能体创建 VS Code 自定义智能体文件,为每个智能体设置专属工具、指令以及向其他智能体的交接。
create-skill
5.8k帮你的智能体创建新的智能体技能,包括有效的名称、清晰的触发描述,以及符合标准的 SKILL.md 文件。
csharp-scripts
5.8k帮你的智能体通过 .NET 命令行工具以单个文件运行小型 C# 程序,无需创建完整项目。
dotnet-pinvoke
5.8k帮你的智能体在 .NET 中正确调用原生 C 或 C++ 库,涵盖函数签名、字符串处理、内存和安全句柄。