Aller au contenu
Skillpedia
Tests5.8k · #14639

test-smell-detection

Ce qu’il fait

Cette compétence audite les tests à l'aide d'une liste formelle et issue de la recherche de défauts de tests, c'est-à-dire de schémas qui rendent les tests plus difficiles à croire ou à maintenir. Elle s'adresse aux développeurs qui veulent une revue nommée et citable de leur code de tests.

Quand l’utiliser

  • ✓Quand vous avez besoin d'une revue nommée et citable des défauts de tests dans une suite de tests.
  • ✓Quand vous voulez savoir quelles catégories de défauts apparaissent et à quel point elles sont graves.
  • ✓Quand une évaluation formelle des défauts, classée par gravité, est demandée pour un projet.

Lien du skill

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-smell-detection/SKILL.md

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-smell-detection/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Fais-moi une revue formelle des défauts de nos fichiers de tests, avec les catégories nommées et une gravité pour chaque constat.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent lit les tests, vérifie chaque candidat par rapport aux catégories nommées en s'appuyant sur le code comme preuve, puis classe les constats confirmés par gravité.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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-extensions catalog, 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

  1. 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.
  2. Read the tests and only verdict-changing production context.
  3. 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.
  4. Rank confirmed findings by risk of false confidence or flakiness, then by maintenance cost.
  5. 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, Pester Should -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
Questions fréquentes

D'où viennent les noms des défauts ?

Les catégories proviennent d'une taxonomie publiée des défauts de tests, comme Assertion Roulette, Conditional Test Logic ou Mystery Guest.

Corrige-t-elle les défauts ?

Elle signale les constats et propose des corrections adaptées au code.

Est-ce la même chose que la revue générale des anti-patterns ?

Non. Elle utilise une taxonomie formelle. Elle convient mieux lorsque vous avez besoin de catégories nommées plutôt que d'une revue générale.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
5.8k
Position au classement
#14639
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires