detect-test-smells
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "detect-test-smells":https://skillpi.com/zh/skills/deepskill-fdcd8710394afca44ee87328da3cb4a7ab3fbaa6974bcdf02083f3c4f766f1db。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
检测 PHP 测试套件中的测试反模式和代码异味。识别 15 种异味(例如测试中的逻辑、过度使用 Mock、脆弱测试、神秘访客等),并提供修复建议与提高可测试性的重构模式。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 减记
- 实测状态
- 未测试
文件浏览
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
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 针对 PHP 测试套件中的反模式和代码异味检测,解决开发者测试质量保障的明确痛点
- 提供 15 种异味的识别模式、修复建议和重构模式,实用性强
- 覆盖高严重性设计问题(如 Mock 滥用、测试间依赖)和日常维护问题(如硬编码数据)
待提升项
-
description写错位置 原报告严重程度:轻微
顶层 frontmatter 中 description 字段为空,实质描述内容位于 skill_body 内部
改进建议:将 description 内容移至顶层 frontmatter 的 description 字段,确保触发词在正确位置
亮点
- 功能描述清晰明确,覆盖 PHP 测试反模式检测的核心场景
- 触发边界清晰,不易与其他 Skill 混淆
亮点
- 结构清晰,包含异味列表、检测命令、输出格式、严重性矩阵和相关技能
- 提供具体 grep 命令示例,便于用户直接执行
- frontmatter 完整,文档组织良好
亮点
- 检测命令基于标准 grep 工具,参数正确,可执行性强
- 输出格式明确,便于用户理解检测结果
- 覆盖主要异常场景,可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。