跳到正文
Skillpedia
测试5.8k · #14638

test-gap-analysis

它能做什么

这项技能寻找生产代码中那些即使在没有任何现有测试失败的情况下也可能被破坏的行为。适合希望知道自己的测试能否捕获真正缺陷的开发者。

适用场景

  • ✓当你想知道现有测试能否捕获某个功能中的真正缺陷时。
  • ✓当你想在某个组件或风险区域中找出未经测试的行为时。
  • ✓当你在添加测试之前需要确认某个疑似的测试缺口确实存在的时候。

技能链接

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-gap-analysis/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-gap-analysis/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“如果结账代码中的折扣计算出错,我现有的测试能发现吗?请找出其中的缺口。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会列出代码向调用方展示的结果,设想小而现实的改动,检查是否有现有测试会失败,并在你要求时验证可信的缺口。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Test Gap Analysis

Answer one question: which caller-visible production behaviors could change without an existing test failing? Mutation reasoning is a probe, not the goal. Inventory public outcomes first, then verify only credible gaps.

Composition dispatch

Before entering the decision flow, check the caller's mode. An explicit per-test-read-only request (including composition from grade-tests) uses only references/per-test-read-only.md. This mode is assessment context conveyed through the host's supported caller instructions, not a new skill-loader parameter or a mode-specific skill name. Read that reference and return its per-test assessment inline; do not enter the standalone workflow below. Loading this mode does not authorize a baseline run, mutation execution, file edits, suite discovery, or delegation. If the bundled reference is unavailable, allow at most one listing of the known references/ directory, then return N/A / unverified with the reason.

Requests without this mode retain the standalone analysis, verification, and test-addition paths below.

Decision flow

1. Set scope

Discover production and test files from manifests and file types. After a narrow search misses, inspect the current directory broadly before asking for paths.

Request Action
One component or named risk Inventory every high-risk public outcome in scope; do not edit production code unless verification was requested
General small-component review Inventory distinct outcomes and report caller-visible gaps from source/assertion mapping
Explicit survivor verification Inventory all requested outcomes; execute one representative observable candidate for each distinct high-risk outcome under verification, then classify it as Survived or Killed
Explicit exhaustive audit Read references/mutation-catalog.md and classify all meaningful candidates
Add tests to an existing suite Analyze first; add tests only for verified survivors or demonstrated no-coverage outcomes
Create a new suite Stop and use code-testing

When the request names a risk, turn it into a one-line public-outcome allowlist before reading code. An outcome is not in scope merely because the same method writes it. For money math, allow computed or returned amounts, rates, tier/boundary choice, percentage base/order, floors/caps, and rounding; exclude non-monetary state predicates (including derived booleans), identity, and formatting. Private code is in scope only to trace an allowed outcome.

Do not expand a focused request into a repository audit, plan artifact, or dashboard. Use source and tests directly for familiar frameworks. When discovery or assertion semantics are unclear, read the matching language file relative to the caller-provided or runtime-listed test-analysis-extensions catalog; do not invoke the reference-only helper or search installation directories. If absent, state the limitation and use the pinned APIs and rules here.

2. Establish one baseline

For a source-only advisory review, skip execution and label empirical survival unverified. A baseline is required when the user requests execution or survivor verification, or when closing gaps with tests. Run the narrowest existing test command once. Choose it from the project manifest; Microsoft.Testing.Platform executables may require dotnet run. Confirm tests executed: exit 0 with build-only output is not green. If that one attempt cannot run the suite, do not troubleshoot the runner or try alternate commands for an advisory review; continue statically and label all candidates unverified. Do not infer a project-configuration cause from missing output; name a cause only when the command reports it.

Missing runner output limits only claims of empirical mutation survival. It does not make source-proven facts tentative: a public outcome with no reaching test is still No coverage, and an exact expected value derived from the unmodified implementation is still actionable. State the baseline limitation once, then give the static source/assertion conclusion directly instead of hedging every row.

For an advisory review such as "would tests catch this?", stop execution after that baseline. Source-to-assertion mapping is sufficient evidence for No coverage and Candidate survivor (unverified). Trace or run the unmodified code once only

常见问题

它会编写缺失的测试吗?

只有在你要求填补缺口时才会。否则它只报告。

这和代码覆盖率一样吗?

不一样。覆盖率显示哪些行被执行了,而这项技能检查行为是否真正受到保护。

它涵盖整个解决方案吗?

可以,但将范围限定在某个组件或风险区域,通常能得到更有针对性的结果。

详情

作者的原始描述

Find caller-visible production changes existing tests would miss through pseudo-mutation analysis; verify candidates or close gaps only when requested. Includes read-only per-test composition for grading. Polyglot. USE FOR: would tests catch a bug, behavioral blind spots, surviving mutations. DO NOT USE FOR: concrete fix/feature revision proof (test-value-evidence); suite taxonomy (test-tagging); .NET coverage, Cobertura, plateaus or coverage-backed priorities (coverage-analysis); named CRAP (crap-score); new suites (code-testing); assertion/smell audits; mutation tools.

repo: dotnet/skills

热度

GitHub 星标
5.8k
排名
#14638
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能