detect-test-smells
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "detect-test-smells" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-fdcd8710394afca44ee87328da3cb4a7ab3fbaa6974bcdf02083f3c4f766f1db. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Detect test anti-patterns and code smells in PHP test suites. Identify 15 smells (for example: logic in tests, excessive use of mocks, brittle tests, mysterious visitors, etc.) and provide remediation suggestions along with refactoring patterns to improve testability.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Detects test antipatterns and code smells in PHP test suites. Identifies 15 smells (Logic in Test, Mock Overuse, Fragile Tests, Mystery Guest, etc.) with fix recommendations and refactoring patterns for testability.
- Inputs and outputs
- ```markdown
- Testing
- Not tested
Browse files
Frontmatter
name: detect-test-smells
description: Detects test antipatterns and code smells in PHP test suites. Identifies 15 smells (Logic in Test, Mock Overuse, Fragile Tests, Mystery Guest, etc.) with fix recommendations and refactoring patterns for testability.Test Smell Detection
Identifies antipatterns and code smells in PHP test suites.
15 Test Smells
| # | Smell | Severity | Detection Pattern |
|---|---|---|---|
| 1 | Logic in Test | High | if/for/while/foreach in tests |
| 2 | Mock Overuse | High | >3 mocks in single test |
| 3 | Test Interdependence | High | static $, @depends |
| 4 | Fragile Test | High | expects(exactly), at() |
| 5 | Mystery Guest | Medium | file_get_contents, getenv |
| 6 | Eager Test | Medium | Multiple unrelated assertions |
| 7 | Assertion Roulette | Medium | >5 assertions without context |
| 8 | Obscure Test | Low | test_it_works, test_foo |
| 9 | Test Code Duplication | Medium | Repeated setup/assertion |
| 10 | Conditional Test Logic | Medium | if.*assert patterns |
| 11 | Hard-Coded Test Data | Low | Magic values in tests |
| 12 | Testing Private Methods | High | setAccessible(true) |
| 13 | Slow Test | Medium | sleep, I/O in unit tests |
| 14 | Mocking Final Classes | High | Mock concrete final classes |
| 15 | Mocking Value Objects | High | Mock readonly/immutable classes |
Quick Detection Commands
# Logic in tests
Grep: "if \(|for \(|while \(|foreach \(" --glob "tests/**/*Test.php"
# Mock overuse (manual count needed)
Grep: "createMock|createStub" --glob "tests/**/*Test.php"
# Test interdependence
Grep: "static \$|@depends" --glob "tests/**/*Test.php"
# Testing private methods
Grep: "setAccessible\(true\)|ReflectionMethod" --glob "tests/**/*Test.php"
# Mystery guest
Grep: "file_get_contents|fopen|getenv|_ENV|_SERVER" --glob "tests/**/*Test.php"
# Fragile tests
Grep: "expects\(.*exactly|expects\(.*at\(" --glob "tests/**/*Test.php"
Output Format
# Test Smell Report
## Summary
| Smell | Count | Severity |
|-------|-------|----------|
| Logic in Test | 5 | High |
| Mock Overuse | 3 | High |
## Findings
### Logic in Test (5 occurrences)
| File | Line | Code |
|------|------|------|
| OrderTest.php | 45 | `foreach ($items as $item)` |
**Recommendation:** Extract to data providers or inline values.
## Action Items
1. **High Priority** — Refactor tests with >5 mocks
2. **Medium Priority** — Inline fixture data
Severity Matrix
| Severity | Smells | Impact |
|---|---|---|
| High | Logic in Test, Mock Overuse, Test Interdependence, Fragile Test, Mocking Final/VO, Testing Private | Unreliable results, design problems |
| Medium | Mystery Guest, Eager Test, Slow Test, Conditional Logic, Duplication | Hard to understand/maintain |
| Low | Obscure Test, Hard-Coded Data | Documentation/readability |
Related Skills
| Smell | Fix With |
|---|---|
| Mock Overuse | create-mock-repository |
| Mystery Guest | create-test-builder |
| Test Duplication | create-test-builder |
References
references/smell-catalog.md— Full smell descriptions with code examplesreferences/refactoring-patterns.md— Refactoring patterns for testability
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 针对 PHP 测试套件中的反模式和代码异味检测,解决开发者测试质量保障的明确痛点
- 提供 15 种异味的识别模式、修复建议和重构模式,实用性强
- 覆盖高严重性设计问题(如 Mock 滥用、测试间依赖)和日常维护问题(如硬编码数据)
Areas to improve
-
Description in the wrong location Reported severity: Minor
顶层 frontmatter 中 description 字段为空,实质描述内容位于 skill_body 内部
Recommendation: 将 description 内容移至顶层 frontmatter 的 description 字段,确保触发词在正确位置
Highlights
- 功能描述清晰明确,覆盖 PHP 测试反模式检测的核心场景
- 触发边界清晰,不易与其他 Skill 混淆
Highlights
- 结构清晰,包含异味列表、检测命令、输出格式、严重性矩阵和相关技能
- 提供具体 grep 命令示例,便于用户直接执行
- frontmatter 完整,文档组织良好
Highlights
- 检测命令基于标准 grep 工具,参数正确,可执行性强
- 输出格式明确,便于用户理解检测结果
- 覆盖主要异常场景,可靠性高
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.