测试失败调试排查
debug-test-failures
用于测试失败的系统化调试工作流。当测试失败、CI 构建变红,或被要求调试测试问题时使用。
- License 许可
- MIT
- 所属仓库
- microsoft/haste
- 最近更新
- 2026-11-13
- Stars
- ★ 110
- Forks
- 19
01 前言 Front Matter
- name
- debug-test-failures
- level
- intermediate
- agents
- [ "backend-dev", "gis", "ui", "backend-validation" ]
- domain
- testing
- source
- Internal engineering practices
- status
- draft
- description
- Systematic debugging workflow for test failures. Use when tests are failing, a CI build is red, or when asked to debug test issues.
- created_date
- 2026-04-27
- validated_by
- allowed-tools
- shell
- last_validated
03 SKILL.md 正文
Debug Test Failures
Overview
A systematic process for diagnosing and fixing test failures. Use this skill when tests fail, CI is red, or someone reports a broken build. The key principle: find the root cause, not just the symptom.
Key Concepts
Failure Categories
- Deterministic failure: Same result every time. Usually a code bug or outdated test.
- Flaky failure: Intermittent. Usually caused by timing, ordering, shared state, or external dependencies.
- Environment failure: Works locally, fails in CI. Usually paths, permissions, or missing dependencies.
Patterns & Techniques
Systematic Debugging Process
Step 1: Reproduce Run the failing test in isolation:
# Python tests
cd hastelib && hatch run test:pytest
# UI lint
cd ui && npm run lint
Run it 2-3 times. If intermittent, it's likely flaky.
Step 2: Analyze
- Read the error message and stack trace carefully
- Identify the assertion that failed: expected vs actual values
- Check if the failure is in the test or the code under test
Step 3: Investigate
- Read the test code to understand what it's testing
- Read the production code being tested
- Check recent changes to both
- Common root causes:
- Changed function signatures or return types
- Modified data structures
- New dependencies not mocked
- Environment differences (paths, timezones, locale)
- Race conditions in async code
Step 4: Fix
- Fix the root cause, not just the symptom
- If the test is wrong (testing outdated behavior), update the test
- If the code is wrong, fix the code
- Run the full test suite:
cd hastelib && hatch run test:pytest
Step 5: Report Summarize: root cause, fix applied, verification that all tests pass.
Decision Framework
| Symptom | Likely Cause | Action |
|---|---|---|
| Test always fails | Code bug or outdated test | Read both, fix the wrong one |
| Test passes locally, fails in CI | Environment difference | Check paths, deps, permissions |
| Test fails intermittently | Timing, shared state, or ordering | Add isolation, remove shared state |
| Many tests fail at once | Breaking change in shared code | Find the common dependency |
Common Pitfalls
- Fixing the test to match broken code — Verify the code is correct before changing the test
- Adding sleep() to fix flaky tests — Fix the root cause (usually missing await or shared state)
- Only running the fixed test — Always run the full suite to check for regressions
04 同仓库更多 Skills
HASTE 实施验证与诊断
validation-diagnostics
HASTE 的验证与诊断技能。对比计划工作与已实现工作,生成诊断报告,并将遗漏项反馈到技能改进中。使用场景:'验证实现'、'对比规格'、'诊断报告'、'偏差分析'、'覆盖检查'、'实现审查'。
Dependabot 漏洞分析与分诊
security-analysis
面向 HASTE 的 Dependabot 与安全分析技能。解析告警、归类相关漏洞、应用严重性规则并生成结构化报告。使用场景:'Dependabot 告警'、'安全扫描'、'漏洞分诊'、'依赖审计'、'npm audit'、'pip audit'、'CVE 分析'。
发布说明与变更日志生成
release-notes
根据提交历史生成发布说明。当需要起草发布说明、创建变更日志或总结某个版本的变更时使用。
HASTE 卫星影像供应商适配
imagery-provider-adaptation
面向 HASTE 的影像供应商适配技能。封装卫星影像来源(Planet、Vantor、Airbus 等)的特定逻辑。适用场景:'new imagery provider'(新影像供应商)、'add source type'(添加来源类型)、'satellite provider'(卫星供应商)、'Planet'、'Vantor'、'Airbus'、'Pleiades'、'WorldView'、'SkySat'、'imagery ingestion'(影像摄取)、'provider adapter'(供应商适配器)。
HASTE 确定性脚本执行
deterministic-scripts
面向 HASTE 的确定性脚本执行技能。使用脚本而非自由形式的 LLM 行为,以实现一致、可重复的操作。适用场景:'run preprocessing'(运行预处理)、'convert format'(转换格式)、'parse metadata'(解析元数据)、'generate tiles'(生成切片)、'build wheel'(构建 wheel 包)、'deploy functions'(部署函数)。防止产生幻觉脚本。
项目依赖安全更新
dependency-update
安全更新项目依赖的指南。当被要求更新软件包、升级依赖项或检查过时库时使用。