test-smell-detection
Was er macht
Dieser Skill prüft Tests anhand einer formalen, forschungsbasierten Liste von Test-Smells, also Mustern, die Tests schwerer vertrauenswürdig oder wartbar machen. Er ist für Entwickler gedacht, die eine benannte, belegbare Prüfung ihres Testcodes wollen.
Wann du ihn nutzt
- ✓Wenn du eine benannte, belegbare Prüfung von Test-Smells in einer Testsuite brauchst.
- ✓Wenn du wissen willst, welche Smell-Kategorien vorkommen und wie schwer sie sind.
- ✓Wenn für ein Projekt eine formale, nach Schwere sortierte Smell-Bewertung verlangt wird.
Link zum Skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-smell-detection/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Gib mir eine formale Test-Smell-Prüfung unserer Testdateien, mit den benannten Kategorien und einem Schweregrad für jeden Befund.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Der Agent liest die Tests, prüft jeden Kandidaten gegen die benannten Smell-Kategorien mit dem Code als Beleg und ordnet die bestätigten Befunde nach Schweregrad.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Test Smell Detection
Audit test code with the academic taxonomy, code evidence, calibrated framework idioms, and fixes native to the codebase.
Scope
- Audit only staged or named tests. Search the current workspace before asking for code; never claim a file is missing until that search finds no relevant test.
- Read production code only when it changes a verdict.
- For unfamiliar framework APIs, read the matching language file relative to
the caller-provided or runtime-listed
test-analysis-extensionscatalog, not a skill invocation. If absent, use the framework and rules here and report the missing reference; do not search installation directories. - Read the complete catalog when the caller requests all 19 smells, asks for citations, or the code may contain a smell outside the high-signal set below. Do not load it for a narrow question that this file answers.
Audit Workflow
- Search for and read the staged tests; detect language, framework, boundaries, and integration markers. This is the first action even when no path is named.
- Read the tests and only verdict-changing production context.
- For each candidate, verify the executed check, choose the formal category, calibrate, then assign severity. Report proven non-catalog test-validity defects separately; do not relabel them as smells.
- Rank confirmed findings by risk of false confidence or flakiness, then by maintenance cost.
- Give a framework-correct replacement for each actionable finding. Never use .NET terminology or APIs in another ecosystem.
High-Signal Decisions
| Evidence | Academic finding | Do | Never |
|---|---|---|---|
Assertion behavior changes behind if, switch, or branching loops |
Conditional Test Logic | Split cases or parameterize them | Flag table-driven or parametrized tests merely because a runner loop exists |
| A test relies on an undeclared file, network service, environment value, or database | Mystery Guest or Resource Optimism | Make the dependency explicit and hermetic; distinguish the two using the full catalog | Condemn an integration test merely for exercising its declared real resource |
| Fixed wall-clock sleep waits for an outcome | Sleepy Test | Await or poll the condition with a timeout | Downgrade it only because the test is an integration test |
| Executable test has no assertion, expected-exception marker, or mock verification | Unknown Test | Assert the observable outcome | Call an empty body Unknown Test; the formal name is Empty Test |
| Async assertion/coroutine is created but not awaited or returned | Critical non-catalog false-pass defect | Report it separately and show the required await/return |
Force it into Unknown Test; the assertion statement exists |
| One test exercises many unrelated production behaviors | Eager Test | Separate behavior-focused tests | Flag a deliberate end-to-end workflow without considering its scope |
| Expected numeric literal has no local meaning | Magic Number Test | Name the domain value or derive it from setup | Flag count == 3 immediately after adding three items |
Assertion depends on ToString, repr, description, or display formatting that is not the contract |
Sensitive Equality | Assert stable fields or use a structural matcher | Flag a test whose explicit contract is the formatted string |
| Test manually manages expected exception flow | Exception Handling | Use the framework's exception assertion and check meaningful details | Claim a capture-and-assert test verifies nothing |
| Shared setup creates state irrelevant to the tests that receive it | General Fixture | Remove unused state or narrow the fixture; rank cheap state low | Condemn relevant shared setup merely because it is shared |
| Test is disabled or skipped | Ignored Test | Report every skip, but rank a tracked, reasoned skip below an unexplained one | Clear a skip because its reason is good, or give both the same urgency |
Calibration Rules
Apply these before assigning a finding:
- Mock-call verifications, snapshots, bare pytest
assert, PesterShould -Invoke, and expected-exception constructs are assertions. - A literal or snapshot assertion may expose a coverage gap, but is not Unknown Test or another smell without separate evidence.
- Count assertion statements. One assertion is never Assertion Roulette; missing messages alone are not a smell.
- Same-method tests are not Lazy Test when the
Häufige Fragen
Woher stammen die Smell-Namen?
Die Kategorien stammen aus einer veröffentlichten Taxonomie von Test-Smells, etwa Assertion Roulette, Conditional Test Logic und Mystery Guest.
Behebt er die Smells?
Er meldet Befunde und schlägt Lösungen vor, die zur Codebasis passen.
Ist das dasselbe wie die allgemeine Anti-Pattern-Prüfung?
Nein. Er nutzt eine formale Taxonomie und eignet sich am besten, wenn du benannte Kategorien statt einer allgemeinen Prüfung brauchst.
Details
Originalbeschreibung des Autors
Audits existing tests in any language using formal, research-backed test smell names and the testsmells.org 19-smell academic taxonomy. Use when the caller asks for an academic or citable test-smell review, named smell categories, or a formal severity-ranked smell assessment. Covers Assertion Roulette, Conditional Test Logic, Mystery Guest, Eager Test, Sleepy Test, Unknown Test, Sensitive Equality, and the rest of the catalog across .NET, Python, JavaScript/TypeScript, Java, Go, Ruby, Rust, Swift, Kotlin, PowerShell, and C++. DO NOT USE FOR a quick pragmatic test review (use test-anti-patterns
repo: dotnet/skills
Beliebtheit
- GitHub-Sterne
- 5.8k
- Platz im Ranking
- #14639
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
create-custom-agent
5.8kHilft deinem Agenten, Agenten-Dateien für VS Code zu erstellen, mit eigenen Werkzeugen, Anweisungen und Übergaben an andere Agenten.
create-skill
5.8kHilft deinem Agenten, einen neuen Agenten-Skill mit gültigem Namen, klarer Auslöserbeschreibung und einer SKILL.md-Datei nach dem Standard zu erstellen.
csharp-scripts
5.8kHilft deinem Agenten, ein kleines C#-Programm als einzelne Datei mit dem .NET-Kommandozeilen-Tool auszuführen, ohne ein vollständiges Projekt anzulegen.
dotnet-pinvoke
5.8kHilft deinem Agenten, native C- oder C++-Bibliotheken korrekt aus .NET aufzurufen, mit Signaturen, Zeichenkettenbehandlung, Speicher und sicheren Handles.
Ähnliche Skills
test-driven-development
311kBringt deinem Agenten bei, vor jedem Feature oder Fix zuerst einen fehlschlagenden Test zu schreiben, ihn fehlschlagen zu sehen und dann den kleinsten passenden Code zu schreiben.
verification-before-completion
311kBringt deinem Agenten bei, echte Prüfungen auszuführen und ihre Ausgabe zu lesen, bevor er behauptet, eine Aufgabe, ein Fix oder ein Build sei fertig oder bestehe.
migrate-to-shoehorn
310kErsetzt riskante Typumwandlungen in deinen Testdateien durch die Bibliothek shoehorn, damit Tests mit unvollständigen Daten arbeiten und trotzdem die Typprüfung bestehen.