失败测试调试排查
debug-failing-test
使用迭代式日志方法调试失败的测试,随后清理现场并记录所学经验。
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 147
- Forks
- 83
01 前言 Front Matter
- name
- debug-failing-test
- description
- Debug a failing test using an iterative logging approach, then clean up and document the learning.
02 资源文件 10
- 参考文档AGENTS.md1.7 KB
- 参考文档references/agents-prompts-skills-projects.md4.6 KB
- 参考文档references/AGENTS.md2.0 KB
- 参考文档references/api-webui.md3.5 KB
- 参考文档references/architecture-runtime.md4.0 KB
- 参考文档references/dox-workflow.md2.8 KB
- 参考文档references/extensions.md4.5 KB
- 参考文档references/operate-agent-zero.md15.2 KB
- 参考文档references/plugins-workflow.md3.7 KB
- 参考文档references/tools.md3.1 KB
03 SKILL.md 正文
Debug a failing unit test by iteratively adding verbose logging, running the test, and analyzing the output until the root cause is found and fixed.
Workflow
Phase 1: Initial Assessment
- Run the failing test to capture the current error message and stack trace
- Read the test file to understand what is being tested
- Read the source file being tested to understand the expected behavior
- Identify the assertion that fails and what values are involved
Phase 2: Iterative Debugging Loop
Repeat until the root cause is understood:
-
Add verbose logging around the suspicious code:
- Use
console.log('[DEBUG]', ...)with descriptive labels - Log input values, intermediate states, and return values
- Log before/after key operations
- Add timestamps if timing might be relevant
- Use
-
Run the test and capture output
-
Assess the logging output:
- What values are unexpected?
- Where does the behavior diverge from expectations?
- What additional logging would help narrow down the issue?
-
Decide next action:
- If root cause is clear → proceed to fix
- If more information needed → add more targeted logging and repeat
Phase 3: Fix and Verify
- Implement the fix based on findings
- Run the test to verify it passes
- Run related tests to ensure no regressions
Phase 4: Clean Up
-
Remove ALL debugging artifacts:
- Delete all
console.log('[DEBUG]', ...)statements added - Remove any temporary variables or code added for debugging
- Ensure the code is in a clean, production-ready state
- Delete all
-
Verify the test still passes after cleanup
Phase 5: Document and Learn
-
Provide a summary to the user (1-3 sentences):
- What was the bug?
- What was the fix?
-
Record the learning by following the learning instructions (if you have them):
- Extract a single, clear learning from this debugging session
- Add it to the "Learnings" section of the most relevant instruction file
- If a similar learning already exists, increment its counter instead
Logging Conventions
When adding debug logging, use this format for easy identification and removal:
console.log('[DEBUG] <location>:', <value>);
console.log('[DEBUG] before <operation>:', { input, state });
console.log('[DEBUG] after <operation>:', { result, state });
Example Debug Session
// Added logging example:
console.log('[DEBUG] getEnvironments input:', { workspaceFolder });
const envs = await manager.getEnvironments(workspaceFolder);
console.log('[DEBUG] getEnvironments result:', { count: envs.length, envs });
Notes
- Prefer targeted logging over flooding the output
- Start with the failing assertion and work backwards
- Consider async timing issues, race conditions, and mock setup problems
- Check that mocks are returning expected values
- Verify test setup/teardown is correct
04 同仓库更多 Skills
VS Code 设置优先级规则
settings-precedence
VS Code 设置优先级规则及常见陷阱。适用于任何读取或写入设置的代码。涵盖 getConfiguration 作用域、inspect() 与 get() 的区别,以及多工作区处理。
VS Code 扩展冒烟测试
run-smoke-tests
运行冒烟测试,在真实 VS Code 环境中验证扩展功能。在更改后检查基本功能是否正常工作时使用。
代码提交前(pre-commit)检查
run-pre-commit-checks
在提交代码前运行强制性的 pre-commit 检查,包括 lint(代码规范检查)、类型检查和单元测试。每次提交前都必须运行。
扩展组件集成测试运行
run-integration-tests
运行集成测试以验证扩展的各个组件能否正确协同工作。在修改组件交互或事件处理后使用此技能。
E2E 端到端测试运行
run-e2e-tests
运行 E2E 测试以验证完整的用户工作流(如环境的发现、创建和选择)。在发布前或进行重大变更后使用此技能。
Python 环境管理器探测
python-manager-discovery
针对特定环境管理器的探测模式及已知问题。在编写或审查 conda、poetry、pipenv、pyenv 或 venv 的环境探测代码时使用。