test-smell-detection
What it does
This skill audits tests using a formal, research-based list of test smells, which are patterns that make tests harder to trust or maintain. It is for developers who want a named, citable review of their test code.
When to use it
- ✓When you need a named and citable review of test smells in a test suite.
- ✓When you want to know which test smell categories appear and how serious they are.
- ✓When a formal, severity-ranked smell assessment is requested for a project.
Skill link
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/test-smell-detection/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Give me a formal test smell review of our test files, with the named categories and a severity for each finding.”
5 new skills a week. 1 minute to read.
How it works
The agent reads the tests, checks each candidate against the named smell categories using the code as evidence, and ranks the confirmed findings by severity.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Where do the smell names come from?
The categories come from a published taxonomy of test smells, such as Assertion Roulette, Conditional Test Logic and Mystery Guest.
Does it fix the smells?
It reports findings and suggests fixes that fit the codebase.
Is it the same as the general anti-pattern review?
No. It uses a formal taxonomy, so it is best when you need named categories rather than a general review.
Details
Original description by the author
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
Popularity
- GitHub stars
- 5.8k
- Ranking position
- #14639
- License
- MIT
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
create-custom-agent
5.8kHelps your agent create VS Code custom agent files with their own tools, instructions and handoffs to other agents.
create-skill
5.8kHelps your agent create a new agent skill with a valid name, a clear trigger description and a SKILL.md file that follows the standard.
csharp-scripts
5.8kHelps your agent run a small C# program as a single file with the .NET command line tool, without creating a full project.
dotnet-pinvoke
5.8kHelps your agent call native C or C++ libraries from .NET correctly, covering signatures, string handling, memory and safe handles.
Similar skills
test-driven-development
311kTeaches your agent to write a failing test first, watch it fail, then write the smallest code that passes, before building any feature or fix.
verification-before-completion
311kTeaches your agent to run real checks and read their output before claiming that a task, fix, or build is complete or passing.
migrate-to-shoehorn
310kReplaces risky type casts in your test files with the shoehorn library, so tests can use partial data and still pass type checks.