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

Fill in the details

Paste the complete test case that is currently failing.

Copy the exact error message or stack trace from the test runner.

Paste the implementation code being tested (optional but recommended).

e.g., Python pytest, JavaScript Jest, Java JUnit.

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

  1. Fill in the fields above. Required ones are marked with *.
  2. Check the prompt preview: your answers appear highlighted in place.
  3. Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
See all Software Development & Coding prompts