Inferensys

Prompt

Bug Report Test Case Generation Prompt for QA

A practical prompt playbook for using Bug Report Test Case Generation Prompt for QA in production AI workflows.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the ideal conditions, required inputs, and clear boundaries for generating executable test cases from bug reports.

This prompt is designed for QA engineers and CI/CD automation pipelines that need to convert a resolved bug report into a targeted, executable test suite. The core job-to-be-done is functional verification: confirming that the specific failure mode described in the bug no longer occurs and that the code changes did not introduce obvious regressions in adjacent functionality. The ideal user is a QA automation engineer or a developer practicing shift-left testing who already has a structured or semi-structured bug ticket containing clear reproduction steps, expected versus actual behavior, and environment details. The prompt assumes the bug has already been triaged, classified, and assigned for remediation—it is not a triage or root-cause analysis tool.

Use this prompt when you have a single, well-scoped bug report and need to generate test cases that can be immediately executed, either manually or as a blueprint for automated test scripts. The required inputs include the bug title, a detailed description, numbered reproduction steps, the observed incorrect behavior, the expected correct behavior, and any relevant environment configuration (OS, browser, version, device). The output is a test suite containing step-by-step instructions, explicit expected results for each step, and edge-case variations that probe the boundaries of the fix. This prompt is optimized for deterministic, functional defects—think null pointer exceptions, incorrect calculations, broken UI interactions, or API contract violations—rather than probabilistic or load-dependent issues.

Do not use this prompt for exploratory testing design, performance or load test planning, security penetration test generation, or usability evaluation. It will not produce useful output for bugs that lack clear reproduction steps or for systemic issues that require architectural refactoring. If the bug report is vague, incomplete, or still in triage, run it through a bug report completeness check or reproduction step extraction prompt first. For high-severity defects in regulated or safety-critical systems, always treat the generated test cases as a starting point that requires human review and augmentation before execution. The next step after reading this section is to prepare your structured bug input and review the prompt template to understand how placeholders map to your bug tracking fields.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Bug Report Test Case Generation Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your workflow before wiring it into a QA pipeline.

01

Good Fit: Structured Bug Reports

Use when: the input bug report contains clear symptoms, reproduction steps, and expected vs. actual behavior. The prompt excels at expanding these into executable test cases. Guardrail: validate that the source report meets a minimum completeness threshold before invoking generation.

02

Bad Fit: Vague User Complaints

Avoid when: the input is a one-line complaint like 'the app crashed' with no environment details or steps. The model will hallucinate plausible but untestable steps. Guardrail: route low-completeness reports to a Missing Information Request Prompt first, then generate test cases only after enrichment.

03

Required Inputs

Must have: bug title, description, reproduction steps, expected result, actual result, and environment details. Nice to have: stack traces, screenshots, affected version, and user impact notes. Guardrail: define a strict input schema and reject generation requests that lack the minimum required fields.

04

Operational Risk: Untestable Output

What to watch: generated test steps that reference UI elements, APIs, or data states that don't exist in the test environment. Guardrail: pair generated test cases with an automated execution step or a human QA review gate. Flag steps that reference unresolvable identifiers for manual correction.

05

Operational Risk: Missing Edge Cases

What to watch: the prompt generates only the happy-path verification and misses boundary conditions, negative tests, or regression scenarios. Guardrail: append an explicit edge-case expansion instruction to the prompt and cross-reference generated tests against a regression test catalog for gap detection.

06

Operational Risk: Fix-Coupled Tests

What to watch: generated test cases that only pass when the specific fix is applied, creating brittle tests that break on any refactor. Guardrail: require that each test case includes a rationale linking it to the reported symptom, not the implementation fix. Review tests for over-specification before acceptance.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready prompt template for generating targeted test cases from bug descriptions, ready to paste and adapt.

This prompt template converts a bug report into a structured set of test cases for QA engineers. It takes the bug description, reproduction steps, and environment details as input and produces a JSON array of test cases, each with clear steps, expected results, and edge-case variations. The output is designed to be directly executable by a QA engineer or ingestible by a test management system.

code
You are a QA test design engineer. Given a bug report, generate a comprehensive set of test cases to verify the fix.

## INPUT
Bug Report:
[BUG_REPORT]

Reproduction Steps:
[REPRODUCTION_STEPS]

Environment:
[ENVIRONMENT_DETAILS]

## OUTPUT SCHEMA
Return a JSON object with a "test_cases" array. Each test case must have:
- "id": string, unique identifier (e.g., "TC-001")
- "title": string, short descriptive title
- "type": enum["happy_path", "edge_case", "regression", "negative"]
- "priority": enum["critical", "high", "medium", "low"]
- "steps": array of strings, ordered and atomic actions
- "expected_result": string, what should happen if the fix works
- "edge_case_variations": array of strings, alternative scenarios to test
- "linked_bug_id": string, reference to the original bug

## CONSTRAINTS
- Each step must be a single, testable action.
- Expected results must be falsifiable (pass/fail determinable).
- Include at least one test case that exactly reproduces the reported failure.
- Include at least two edge-case variations per test case.
- If the bug report lacks sufficient detail for a step, mark it with "[NEEDS CLARIFICATION]" instead of guessing.
- Do not invent environment details not present in the input.

## EXAMPLE
Input Bug: "Login button does nothing when clicked on mobile Chrome."
Output:
{
  "test_cases": [
    {
      "id": "TC-001",
      "title": "Verify login button triggers authentication on mobile Chrome",
      "type": "happy_path",
      "priority": "critical",
      "steps": [
        "Open the application in mobile Chrome on Android.",
        "Navigate to the login page.",
        "Enter valid credentials.",
        "Tap the login button."
      ],
      "expected_result": "User is authenticated and redirected to the dashboard.",
      "edge_case_variations": [
        "Tap login button rapidly multiple times.",
        "Tap login button while page is still loading assets."
      ],
      "linked_bug_id": "BUG-123"
    }
  ]
}

## RISK_LEVEL: [RISK_LEVEL]
If RISK_LEVEL is "high", add a "regression_risk_notes" field to each test case explaining what adjacent functionality might break.

To adapt this prompt, replace the square-bracket placeholders with real values before execution. [BUG_REPORT] should contain the full unstructured or structured bug description. [REPRODUCTION_STEPS] should be the numbered steps from the report, or an empty string if none were provided. [ENVIRONMENT_DETAILS] should include OS, browser, app version, and device information. [RISK_LEVEL] accepts "low", "medium", or "high" and controls whether regression risk notes are generated. If your test management system expects a different schema, modify the OUTPUT SCHEMA block accordingly, but keep the constraints on step atomicity and falsifiability. Always validate the output against the schema before ingesting it into your test pipeline.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the prompt needs to work reliably. Validate each before execution.

PlaceholderPurposeExampleValidation Notes

[BUG_DESCRIPTION]

The raw, unstructured bug report text from the user or support system

When I click save on the profile page, the app crashes and I lose all my changes. Chrome on Windows.

Check string length > 20 chars. Reject empty or whitespace-only input. Null not allowed.

[COMPONENT_CATALOG]

A maintained list of valid components, modules, or services the bug could map to

["user-profile", "billing", "auth", "search-index"]

Must be a non-empty array of strings. Validate against current service registry before execution.

[SEVERITY_RUBRIC]

The organization's severity definitions (S1-S4) with criteria for blast radius and user impact

S1: Complete outage, all users blocked. S2: Critical feature broken, no workaround...

Must contain at least 4 severity levels with distinct, non-overlapping criteria. Schema check required.

[KNOWN_DUPLICATES]

A list of existing open bug tickets to compare against for duplicate detection

[{"id": "BUG-421", "title": "Profile save crash on Chrome", "component": "user-profile"}]

Array of objects with id and title fields required. Empty array allowed if no known duplicates exist.

[DEPLOYMENT_TIMELINE]

Recent deployment events with timestamps and changed services for regression flagging

[{"service": "user-profile", "version": "v2.4.1", "deployed_at": "2025-03-14T10:00:00Z"}]

Array of objects with service, version, and deployed_at fields. deployed_at must parse as ISO 8601. Null allowed if timeline unavailable.

[TEAM_OWNERSHIP_MAP]

Mapping of components to owning teams and current on-call rotation for routing

{"user-profile": {"team": "profile-eng", "on_call": "alex@corp.com"}}

Object with component keys. Each value must have team and on_call fields. Validate on-call contact is current via roster check.

[OUTPUT_SCHEMA]

The target JSON schema for the structured test case output

{"type": "object", "required": ["test_steps", "expected_results", "edge_cases"]}

Must be a valid JSON Schema object. Validate with schema parser before prompt execution. Reject if required fields are missing from schema definition.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the test case generation prompt into a QA pipeline with validation, retries, and human review gates.

The test case generation prompt is designed to be called programmatically from a QA automation service, a CI/CD pipeline, or an internal triage tool. The harness should treat the prompt as a stateless function: it receives a structured bug report as input and returns a set of test cases. The calling system is responsible for providing the bug context, managing the model request, validating the output, and deciding whether the generated tests are ready for a test run or require human review before execution.

Start by constructing the input payload. The [BUG_REPORT] placeholder expects a structured object containing at minimum a title, description, reproduction steps, expected versus actual results, and environment details. If your bug tracker stores these fields separately, assemble them into a single context block before calling the prompt. For model choice, a capable mid-tier model such as GPT-4o or Claude 3.5 Sonnet works well for this structured generation task. Set temperature low (0.0–0.2) to maximize determinism in test step ordering and expected-result phrasing. The output schema should be enforced either through the model's native structured output mode (e.g., response_format with a JSON schema) or by appending a strict [OUTPUT_SCHEMA] block to the prompt that defines the expected array of test case objects, each containing testId, title, preconditions, steps (ordered list), expectedResult, and edgeCaseVariations.

After receiving the model response, run a validation layer before the test cases enter any execution queue. Check that every generated test case includes at least one step that directly reproduces the reported failure mode—this is the minimum bar for usefulness. Validate schema compliance: every testId must be unique, every steps array must be non-empty, and edgeCaseVariations should not simply repeat the primary steps. Implement a retry policy for malformed outputs: if validation fails, re-invoke the prompt once with the same input and an added [CONSTRAINTS] note flagging the specific validation error. If the second attempt also fails, escalate to a human QA lead rather than silently dropping the output.

For high-severity bugs (S1/S2), route generated test cases to a manual review queue before they are added to a test run. The review interface should display the original bug report alongside the generated tests so a QA engineer can confirm coverage of the failure mode and adjust edge cases. For lower-severity bugs, you can auto-approve tests that pass schema validation and the failure-mode coverage check, but log the decision for audit. Store every generated test case with a trace back to the source bug report ID, the prompt version used, and the model identifier—this makes it possible to debug regressions in test generation quality when the prompt or model changes.

Avoid wiring this prompt directly into an automated test execution engine without a human-in-the-loop step for at least the first few dozen runs. Generated test steps may reference UI elements, API endpoints, or data fixtures that don't exist in your test environment. A dry-run validation that checks whether referenced resources are resolvable can catch many of these failures before they waste execution time. Over time, build a small golden dataset of bug-report-to-test-case pairs that your QA team has reviewed and approved; use this dataset to run regression evals whenever you modify the prompt or upgrade the model.

IMPLEMENTATION TABLE

Expected Output Contract

Each generated test case must conform to this schema. Validate output before accepting it into the test management system.

Field or ElementType or FormatRequiredValidation Rule

test_cases

Array of objects

Array length >= 1. Reject if empty.

test_cases[].id

String, UUID v4

Must match UUID v4 regex. Reject on collision within array.

test_cases[].title

String, max 120 chars

Must contain the bug symptom keyword from [BUG_DESCRIPTION]. Reject if generic placeholder like 'Test Case 1'.

test_cases[].reproduction_steps

Array of strings

Each step must be an imperative sentence starting with a verb. Minimum 2 steps. Reject if any step is empty or purely descriptive.

test_cases[].expected_result

String

Must describe observable behavior, not internal state. Reject if it matches the bug symptom without indicating correct behavior.

test_cases[].edge_case_variations

Array of objects with 'scenario' and 'expected_result' keys

If present, each variation must have non-empty 'scenario' and 'expected_result'. Null allowed for the array itself.

test_cases[].linked_bug_id

String

Must equal the provided [BUG_ID] exactly. Reject on mismatch.

test_cases[].priority

Enum: 'critical', 'high', 'medium', 'low'

Must be one of the four enum values. Reject on case mismatch or unknown value.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating test cases from bug reports and how to guard against it.

01

Hallucinated Reproduction Steps

What to watch: The model invents plausible-sounding steps that don't appear in the bug report, creating tests that verify the wrong behavior. This is especially common when the report is vague or uses domain jargon the model over-interprets. Guardrail: Require the model to cite the specific sentence or log line from the bug report that justifies each test step. If no source exists, the step must be flagged with [INFERRED] and held for human review before execution.

02

Missing Edge-Case Variations

What to watch: The prompt generates only the happy-path verification test and omits boundary conditions, null inputs, concurrency scenarios, or stateful side effects mentioned in the bug report. The fix passes the generated test but fails in production because the edge case wasn't covered. Guardrail: Add a mandatory output section for edge-case variations with a minimum count (e.g., 3). Use a second-pass validator prompt that checks whether each edge case maps to a risk signal in the original report.

03

Untestable or Ambiguous Expected Results

What to watch: Expected results use vague language like 'works correctly' or 'no errors' instead of specific, observable assertions. QA engineers can't automate or manually verify these tests reliably. Guardrail: Constrain the output schema to require expected results as boolean-verifiable statements. Add a validation check that rejects any expected result containing subjective adverbs ('properly', 'correctly', 'quickly') without a measurable criterion.

04

Environment Assumption Drift

What to watch: The model assumes a default environment (latest Chrome, production API, admin user) that doesn't match the reporter's actual setup. Generated test cases pass in the assumed environment but can't reproduce the original bug. Guardrail: Extract and pin environment details from the bug report into a structured block before test generation. If OS, browser, version, or user role are missing, the prompt must emit [ENVIRONMENT_UNKNOWN] warnings and generate variant tests for the most common configurations.

05

Fix Verification Tunnel Vision

What to watch: The generated tests only verify the exact failure mode described and ignore regression risks in adjacent functionality. The fix ships, the original bug is closed, but a new bug appears one sprint later in a related code path. Guardrail: Include a regression-risk section in the output that lists components, APIs, or workflows that share state or logic with the buggy area. Use a component dependency map as optional input context to make these suggestions data-driven rather than speculative.

06

Schema Drift in Structured Output

What to watch: The model occasionally drops required fields, nests objects incorrectly, or uses string values where enums are expected, breaking downstream test automation pipelines that parse the output. Guardrail: Validate every generated test case against a strict JSON schema before it enters the test management system. On validation failure, retry once with the schema violation error message injected into the prompt. If the retry also fails, route to a human QA lead with the raw bug report and partial output attached.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of generated test cases before shipping the prompt to production. Each criterion should be checked against a representative sample of bug reports.

CriterionPass StandardFailure SignalTest Method

Reproduction Step Coverage

Generated test steps cover the exact failure mode described in [BUG_REPORT] and include the specific conditions that trigger the bug

Test steps describe a different workflow than the reported bug, or omit the critical precondition that causes the failure

Manual comparison: map each generated step to a sentence in the original bug report; flag unmapped steps as extraneous and uncovered report details as gaps

Expected Result Accuracy

Expected results correctly distinguish between the buggy behavior (what currently happens) and the fixed behavior (what should happen) for each step

Expected results describe only the fixed behavior without acknowledging the current failure, or describe a different failure than the one reported

Spot-check 10 generated test cases: verify that the 'expected result after fix' matches the acceptance criteria implied by the bug report

Edge Case Identification

Generated test cases include at least 2 edge-case variations that probe boundary conditions related to the reported failure (e.g., empty input, max values, concurrent access, permission boundaries)

Edge cases are generic (e.g., 'test with null') and unrelated to the specific bug domain, or no edge cases are generated at all

Count edge cases per generated output; verify each edge case has a plausible connection to the bug's root cause or affected component

Test Step Atomicity

Each test step describes a single, verifiable action with one observable outcome; no step combines multiple actions or assertions

Steps contain compound actions (e.g., 'log in and navigate to settings and click save') or embed assertions inside action descriptions

Parse generated steps: flag any step containing 'and' that joins multiple verbs; verify each step can be executed and checked independently

Environment Detail Preservation

Generated test cases carry forward all environment details from [BUG_REPORT] (OS, browser, app version, device) and mark missing details as 'UNKNOWN' rather than guessing

Environment fields are hallucinated (e.g., 'Windows 11' when the report didn't specify OS) or silently dropped from the output

Diff environment block against source report: flag any added value not present in the original; flag any original detail absent from the output

Executable by a Different QA Engineer

A QA engineer unfamiliar with the original bug can execute the test case without reading the source report and still reproduce the failure

Test case assumes implicit knowledge (e.g., 'use the same account as before') or references internal IDs without explanation

Hand off 5 generated test cases to a QA engineer who hasn't read the source bug report; measure whether they can execute the test and observe the failure within 10 minutes

Schema Compliance

Output strictly matches the [OUTPUT_SCHEMA] with all required fields present, correct types, and enum values within allowed sets

Output is missing required fields, contains extra fields not in the schema, or uses string values where enums are specified

Automated JSON Schema validation: run the output through a schema validator configured with the expected schema; reject any output that fails validation

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single model call and minimal post-processing. Accept raw markdown or plain-text test case output instead of enforcing strict JSON schema. Focus on getting useful test steps, expected results, and edge cases from the bug report without building validation infrastructure.

Simplify the prompt by removing [OUTPUT_SCHEMA] and [CONSTRAINTS] placeholders. Replace them with inline instructions like: Return test cases as a numbered list with steps, expected results, and edge cases.

Watch for

  • Inconsistent output structure across runs makes downstream parsing brittle
  • Missing edge-case variations when the bug report is sparse
  • Test steps that reference UI elements not present in the described environment
  • Overly broad instructions producing generic test cases unrelated to the specific failure mode
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.