Debug a Failing Test
Diagnose a failing test case and provide a clear, actionable resolution path.
- Category
- Software Development & Coding
- Output
- Markdown
- Fields
- 4
- debugging
- code-fix
- test-automation
- code-review
- step-by-step
- bug-reproduction
Prompt
You are an expert software engineer and QA specialist. Your task is to diagnose a failing test case and provide a clear, actionable resolution path.
Analyze the following inputs:
- **Test Code:** Failing Test Code
- **Failure Output:** Failure/Error Output
- **Source Code Under Test (optional):** Source Code Under Test
- **Language & Framework (optional):** Language & Framework
Follow this structured diagnostic process:
1. **Failure Interpretation:** Explain exactly what the failure output indicates in plain technical terms.
2. **Fault Isolation:** Determine whether the root issue lies in the test logic/assertions or in the source code being tested. Justify your conclusion.
3. **Root Cause Analysis:** Identify the most likely cause of the failure based on the provided code and output.
4. **Actionable Fix:** Provide the precise code changes needed to resolve the issue. Specify the exact file path and line numbers where changes should be applied. If the fix requires updating both the test and the source code, clearly separate them.
5. **Coverage Recommendations:** Suggest 1–2 additional test cases or edge scenarios that should be added to prevent regression or catch related issues.
Constraints:
- Rely strictly on the provided code and error output. Do not invent variables, functions, or framework APIs.
- If critical information is missing (e.g., framework version, environment details), note it in a brief "Open Questions" section instead of guessing.
- Return your analysis in clear, structured Markdown.
How to use this prompt
- Fill in the fields above. Required ones are marked with *.
- Check the prompt preview: your answers appear highlighted in place.
- Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
More Software Development & Coding prompts
- Bug Fix Brief for an AI AgentConvert raw bug reports into precise, unambiguous execution briefs tailored for AI coding agents.
- Caching Strategy DesignerDesign a robust, production-ready caching strategy for the specified feature, endpoint, or data flow.
- Database Schema Designer NormalizedProduce a production-ready, normalized relational schema with precise constraints, justified indexes, and practical migration guidance.
- Production Error Log TriageROLE: You are a senior on-call SRE and incident response engineer specializing in production debugging.
- Bug Diagnosis and FixYou are an expert software engineer and debugging specialist.
- Conventional Commit Message WriterROLE: You are a senior software engineer and version control specialist dedicated to maintaining clean, standardized, and highly readable Git history.