本文へスキップ
Skillpedia
テスト5.8k · #14623

assertion-quality

できること

このスキルは、テストコード内のチェック、つまりアサーションを確認し、その意味のある程度と多様性を評価します。テストが通るのに、実際にはほとんど確認していないのではと疑う開発者向けです。

使う場面

  • ✓テストが値がnullでないことや存在することだけを確認し、実際の結果は確認していないとき。
  • ✓常に真になる、または自己参照するアサーションを見つけたいとき。
  • ✓テストスイートが通るけれど、本当のバグを捕まえられるか不安なとき。

スキルのリンク

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/assertion-quality/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/assertion-quality/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私たちのテストはすべて通りますが、ほとんど確認していないのではと不安です。アサーションの強さを確認してもらえますか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントはテストコードと対象のコードを読み、各チェックが何を確認しているかで分類します。そして、弱い箇所をメトリクスの要約とともに報告します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Assertion Diversity Analysis

Analyze test code in any supported language to measure how varied and meaningful the assertions are. Produce a metrics report that reveals whether tests verify different facets of correctness — not just "output equals X" but also structure, exceptions, state transitions, side effects, and invariants.

Language-specific guidance: Read the caller-provided or runtime-listed test-analysis-extensions catalog, then its matching language file (dotnet.md, python.md, typescript.md, go.md, etc.). test-analysis-extensions is reference-only; do not invoke it as a skill. If the bundle is absent, use the pinned framework and this skill's rules, report the missing reference, and do not search installation directories.

Why Assertion Diversity Matters

Low assertion diversity signals shallow testing. Tests may pass while bugs hide in unasserted logic. Common symptoms:

Problem Symptom Consequence
Trivial assertions Test contains only Assert.IsNotNull(result) / assert result is not None / expect(x).toBeDefined() Test passes but doesn't verify correctness
Single-value obsession Always check one field or return value Bugs in unasserted logic slip through
No negative assertions Never check what shouldn't happen Regressions sneak in through false positives
No state checks Don't verify object state changes Missed side-effects or lifecycle issues
No structural checks Only assert top-level value Bugs in nested objects go unnoticed
Assertion-free tests Tests that call but don't verify Code coverage lies; false security

When to Use

  • User asks to evaluate assertion quality or depth
  • User asks "are my tests actually testing anything meaningful?"
  • User wants to know if test assertions are too shallow or trivial
  • User asks for assertion coverage metrics or diversity analysis
  • User suspects tests give false confidence despite passing
  • The test-engineer agent (or any test-generation workflow) calls this skill as a pre-completion self-review step on freshly generated tests, before declaring the run finished

When Not to Use

  • User wants to write new tests (use code-testing for any language, or writing-mstest-tests for MSTest specifically)
  • User wants to detect anti-patterns beyond assertions (use test-anti-patterns)
  • User wants to fix or rewrite assertions (help them directly)
  • User asks about code coverage percentages (out of scope — this analyzes assertion quality, not line coverage)

Inputs

Input Required Description
Test code Yes One or more test files or a test project directory to analyze
Production code No The code under test, to evaluate whether assertions cover the important behaviors

Workflow

Step 1: Detect language and load extension

Identify the language and test framework. Read the corresponding file in extensions/ relative to the supplied test-analysis-extensions catalog. Use that catalog for other language filenames. Check only that known directory when necessary; an unavailable reference changes the evidence limit, not the workspace root or the requested review.

Step 2: Gather the test code

Read all test files the user provides. If the user points to a directory or project, scan for all test files using the markers in the language extension file (e.g., [TestMethod] for MSTest, def test_* for pytest, it() / test() for Jest, func TestXxx for Go).

Step 3: Classify every assertion

For each test method, identify all assertions and classify them into these language-neutral categories:

Category What it verifies Examples across languages
Equality Return value matches expected Assert.AreEqual (MSTest), Assert.Equal (xUnit), assert x == y (pytest), expect(x).toBe(y) (Jest), assertEquals (JUnit), if got != want { t.Error... } / assert.Equal(t, want, got) (Go), x shouldBe y (Kotest), Should -Be (Pester), EXPECT_EQ (GoogleTest)
Boolean Condition holds Assert.IsTrue, assert flag (Python), expect(x).toBeTruthy() (Jest), assertTrue (JUnit), assert.True(t, ok) (testify), x.shouldBeTrue() (Kotest), Should -BeTrue (Pester), EXPECT_TRUE
Null / None / Nil Presence/absence of value Assert.IsNull (.NET), assert x is None (pytest), `ex
よくある質問

弱いテストも直しますか?

いいえ。直接の修正は他のテストスキルで扱います。このスキルは分析レポートを作ります。

どのフレームワークに対応していますか?

MSTest、Jest、pytest、Goなど、いくつかのフレームワークに対応しています。

新しいテストを書きますか?

いいえ。新しいテストケースの作成は、別のテストスキルで扱います。

詳細

作者による元の説明

Analyze assertion quality, depth, variety, and false confidence in existing tests. ALWAYS USE when asked about weak, shallow, trivial, always-true, self-referential, assertion-free, presence/truthiness-only, or insufficiently diverse assertions, including MSTest, Jest, pytest, and Go. DO NOT USE for direct fixes: writing-mstest-tests owns supplied MSTest assertions; code-testing owns new cases. Use test-gap-analysis when asked whether tests would catch a production change, and test-anti-patterns for general severity-ranked audits.

repo: dotnet/skills

人気

GitHubのスター
5.8k
ランキング
#14623
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル