This prompt is designed for test engineers and QA leads who need to systematically build unhappy-path coverage from existing happy-path Gherkin scenarios. The job-to-be-done is translating a set of positive behavior specifications into a comprehensive catalog of negative scenarios that exercise system boundaries, error handling, and failure modes. The ideal user has a set of validated happy-path .feature files and understands the system's architectural boundaries—APIs, databases, external dependencies, and authorization models—that are likely to fail. This is not a prompt for generating initial acceptance criteria from user stories; use the User Story to Gherkin Scenario Prompt Template for that upstream task.
Prompt
Negative Scenario Generation Prompt for Gherkin

When to Use This Prompt
Define the job, ideal user, required inputs, and constraints for generating negative Gherkin scenarios from happy-path acceptance criteria.
Do not use this prompt when the happy-path scenarios themselves are ambiguous or incomplete. The quality of negative scenario generation depends entirely on the clarity of the positive cases and the explicit declaration of system constraints. If your happy-path scenarios contain vague steps like 'the system processes the request' without specifying what processing entails, the resulting negative scenarios will be equally vague and untestable. Similarly, avoid this prompt when you lack access to the system's technical boundaries—negative scenarios must map to specific failure points such as a particular API timeout, a database constraint violation, or an authorization check. Without this mapping, you will generate generic 'what if it fails' scenarios that add noise rather than coverage.
Before running this prompt, prepare three inputs: (1) a set of happy-path Gherkin scenarios with clear actors, actions, and expected outcomes; (2) a system boundary document listing external dependencies, data constraints, and authorization rules; and (3) a risk classification for each boundary (e.g., 'payment gateway timeout: high risk, requires human review'). After generation, validate that every negative scenario references a specific system constraint and produces a distinct, observable expected behavior. Scenarios that merely negate the happy path without a concrete failure mechanism should be discarded or rewritten. For high-risk domains like payments, healthcare, or access control, always route the generated scenarios through a human review step before adding them to your test suite.
Use Case Fit
Where the Negative Scenario Generation Prompt for Gherkin works and where it does not.
Good Fit: Happy Path Exists
Use when: you have a complete, validated happy-path Gherkin scenario with clear actors, actions, and expected outcomes. Guardrail: the prompt requires a concrete system boundary to invert; without it, negative scenarios become arbitrary and untestable.
Bad Fit: Vague Requirements
Avoid when: the source material is a one-line user story or a verbal description with no defined system boundaries. Guardrail: run the Ambiguous Requirement Clarification Prompt first to surface hidden assumptions before attempting negative scenario generation.
Required Inputs
What you need: a Gherkin scenario with explicit Given preconditions, When actions, and Then outcomes, plus a defined system boundary or API contract. Guardrail: missing actors or implicit state will produce negative scenarios that cannot be mapped to real test conditions.
Operational Risk: Overgeneration
What to watch: the model may generate an unbounded list of negative scenarios, many of which are low-value or untestable. Guardrail: constrain output with a fixed taxonomy of failure categories (invalid input, unauthorized access, timeout, dependency failure) and require each scenario to map to a specific constraint.
Operational Risk: Missing System Boundaries
What to watch: negative scenarios that test conditions outside the system under test, such as network failures the test harness cannot simulate. Guardrail: require each scenario to include a testability note indicating whether it requires stubs, mocks, or environment manipulation.
Variant: Authorization-Focused
Use when: the happy path assumes a specific role or permission level. Guardrail: pair this prompt with the Authorization Rule Acceptance Criteria Prompt to ensure role hierarchy, cross-tenant access, and permission inheritance are covered in the negative scenario set.
Copy-Ready Prompt Template
A reusable prompt template for generating negative-path Gherkin scenarios from happy-path acceptance criteria, ready to copy into your AI harness.
This template takes a set of happy-path Gherkin scenarios and a system context description, then produces a corresponding set of negative scenarios. It forces the model to identify system boundaries, constraints, and failure modes before generating any output. The prompt is designed to be used inside an application pipeline where the output will be validated, versioned, and reviewed before merging into a test suite. Copy the block below, replace the square-bracket placeholders with your actual inputs, and wire it into your test generation workflow.
textYou are a test design engineer specializing in negative-path coverage for behavior-driven development. Your task is to generate negative Gherkin scenarios from a set of happy-path acceptance criteria. ## INPUT [HAPPY_PATH_GHERKIN] ## SYSTEM CONTEXT [SYSTEM_CONTEXT] ## CONSTRAINTS [CONSTRAINTS] ## OUTPUT SCHEMA Return a JSON object with the following structure: { "boundary_analysis": [ { "boundary_id": "string", "boundary_description": "string", "failure_modes": ["string"] } ], "negative_scenarios": [ { "scenario_id": "string", "scenario_name": "string", "tags": ["string"], "mapped_boundary_id": "string", "mapped_happy_path_id": "string or null", "gherkin": "string" } ], "coverage_gaps": ["string"] } ## INSTRUCTIONS 1. Parse the happy-path scenarios and identify every system boundary, external dependency, input constraint, authorization check, and resource limit implied or stated. 2. For each boundary, enumerate plausible failure modes: invalid inputs, missing inputs, unauthorized access, timeouts, resource exhaustion, dependency unavailability, and data corruption. 3. Generate at least one negative Gherkin scenario per boundary. Each scenario must include: - A descriptive Scenario name prefixed with "Negative:" - Tags for the failure category (e.g., @invalid-input, @unauthorized, @timeout, @resource-exhaustion) - A Given step that establishes the precondition and the specific boundary being tested - A When step that triggers the failure condition - A Then step that asserts the expected error behavior, error code, or degradation mode 4. Map every negative scenario to exactly one boundary from your analysis. If a scenario does not map to a specific boundary, do not include it. 5. If the happy-path scenarios reference external systems (APIs, databases, auth providers), generate scenarios for each dependency failure mode. 6. List any coverage gaps where the happy-path scenarios lack enough detail to generate confident negative tests. 7. Do not invent system behavior. If the happy-path scenarios or system context do not specify error handling, mark the scenario with @assumed-behavior and note the assumption. ## EXAMPLES Example happy-path input: Scenario: User creates an order with valid items Given the user is authenticated And the user has items in their cart When the user submits the order Then the order is created with status "confirmed" And the inventory is decremented Example negative output: { "boundary_analysis": [ { "boundary_id": "auth-check", "boundary_description": "Authentication gate before order submission", "failure_modes": ["unauthenticated request", "expired token", "insufficient permissions"] } ], "negative_scenarios": [ { "scenario_id": "neg-order-001", "scenario_name": "Negative: Unauthenticated user attempts order submission", "tags": ["@unauthorized", "@auth"], "mapped_boundary_id": "auth-check", "mapped_happy_path_id": null, "gherkin": "Scenario: Negative: Unauthenticated user attempts order submission\n Given the user is not authenticated\n When the user submits an order request\n Then the response status is 401\n And the response body contains an error code 'UNAUTHENTICATED'\n And no order is created" } ], "coverage_gaps": [] } ## RISK LEVEL [RISK_LEVEL] If RISK_LEVEL is "high", every scenario tagged @assumed-behavior must include an explicit note that human review is required before the scenario is considered valid.
To adapt this template, start by replacing [HAPPY_PATH_GHERKIN] with the actual Gherkin text from your feature files. The [SYSTEM_CONTEXT] placeholder should contain a concise description of the system architecture, including external dependencies, authentication mechanisms, data stores, and known rate limits or quotas. For [CONSTRAINTS], specify any domain-specific rules that must not be violated, such as regulatory requirements, data residency rules, or maximum acceptable latency. Set [RISK_LEVEL] to "high" when the system under test handles payments, personal data, health information, or safety-critical operations; this activates the human-review requirement for assumed behaviors. After generating output, validate that every scenario in the negative_scenarios array has a non-empty mapped_boundary_id that matches an entry in boundary_analysis. If the model produces scenarios without clear boundary mappings, reject the output and retry with more explicit system context. The coverage_gaps field is your signal to go back to the requirements author and request more detail before the negative test suite can be considered complete.
Prompt Variables
Required inputs for the Negative Scenario Generation Prompt. Each placeholder must be populated before the prompt is sent to the model. Missing or malformed inputs are the most common cause of irrelevant or untestable negative scenarios.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[HAPPY_PATH_GHERKIN] | The positive-path Gherkin scenario or feature file from which negative scenarios are derived | Feature: Checkout Scenario: Successful purchase with valid credit card Given a user with items in cart When the user submits payment Then the order is confirmed | Must contain at least one complete Scenario with Given, When, and Then steps. Parse check: confirm |
[SYSTEM_BOUNDARY] | The specific system, API, or component boundary under test for negative scenario generation | Payment Gateway API v2 | Must be a named boundary, not a generic label like 'the system'. Validation: reject values under 3 characters or values matching a blocklist of vague terms (system, app, backend). This field scopes failure injection to a specific interface. |
[CONSTRAINT_CATALOG] | A structured list of known constraints, limits, and rules for the system boundary |
| Must contain at least 3 discrete constraints. Each constraint should be a single line with a clear limit or rule. Parse check: split on newlines, count non-empty lines. Fewer than 3 constraints produces shallow negative coverage. Null allowed only if constraints are embedded in [HAPPY_PATH_GHERKIN]. |
[FAILURE_MODE_CATEGORIES] | The classes of failure to generate scenarios for, selected from a controlled taxonomy | invalid_input, unauthorized_access, resource_exhaustion, dependency_failure, timeout | Must be a comma-separated list drawn from the allowed taxonomy: invalid_input, unauthorized_access, resource_exhaustion, dependency_failure, timeout, state_violation, race_condition, data_corruption. Reject any term not in the taxonomy. At least one category required. |
[ACTOR_ROLES] | The user or system roles that interact with the boundary, used to generate unauthorized access scenarios | anonymous_user, authenticated_buyer, merchant_admin, payment_processor | Must be a comma-separated list of at least 2 distinct role names. Each role should be a snake_case identifier. Required when unauthorized_access is in [FAILURE_MODE_CATEGORIES]; otherwise optional. Null allowed if no authorization scenarios are requested. |
[OUTPUT_FORMAT] | The desired Gherkin output structure and any additional fields required | {"scenario": "Scenario: ...", "failure_category": "invalid_input", "mapped_constraint": "Max payment amount: $10,000", "expected_error": "HTTP 422 with code AMOUNT_EXCEEDED"} | Must be a valid JSON schema or example structure. Parse check: valid JSON. If the field contains a natural-language description instead of a schema, flag for human review. The output contract must be machine-parseable for downstream test automation. |
[MAX_SCENARIOS_PER_CATEGORY] | The upper bound on how many negative scenarios to generate per failure mode category | 3 | Must be an integer between 1 and 10. Values above 10 risk generating redundant or low-signal scenarios. Parse check: integer, range check. Default to 3 if null. |
Implementation Harness Notes
How to wire the Negative Scenario Generation Prompt into a test engineering workflow with validation, retries, and model selection.
This prompt is designed to be called programmatically as part of a test generation pipeline, not as a one-off chat interaction. The typical integration point is after a set of happy-path Gherkin scenarios has been approved. A test management system or CI job sends the happy-path scenarios as [INPUT] along with a [SYSTEM_BOUNDARY] description (e.g., 'REST API /orders', 'database write path', 'third-party payment webhook') and a [CONSTRAINT_LIST] derived from the system's non-functional requirements. The prompt returns a structured list of negative scenarios, each with a Gherkin body and a boundary_mapping field that ties it to a specific constraint. Your application should parse this output and insert each scenario into your test case management tool with a tag linking it to the originating happy-path scenario for traceability.
Validation is critical because a malformed Gherkin scenario can break downstream automation. Implement a post-processing validator that checks: (1) every scenario has a Scenario: keyword, (2) every step begins with Given, When, or Then, (3) the boundary_mapping field references a constraint present in the submitted [CONSTRAINT_LIST], and (4) no scenario duplicates a step sequence already present in the happy-path input. If validation fails, use a retry loop with a maximum of 2 additional attempts, feeding the specific validation errors back into the prompt's [PREVIOUS_OUTPUT] and [VALIDATION_ERRORS] placeholders. Log every validation failure and the final accepted output for auditability. For model choice, a mid-tier model like claude-3-5-sonnet or gpt-4o provides sufficient reasoning for constraint mapping without excessive latency; avoid smaller, faster models that may hallucinate Gherkin syntax under the structured output requirements.
Do not send this prompt's output directly to an automated test execution environment without human review if the system under test handles safety-critical functions, financial transactions, or personally identifiable information. In those contexts, route the generated scenarios to a QA lead for approval before they enter the automation suite. For lower-risk systems, you can auto-approve scenarios where the boundary_mapping confidence score (if you add one to the output schema) exceeds a threshold, and flag the rest for review. The primary failure mode in production is the model generating scenarios that are syntactically valid but semantically nonsensical—for example, testing a 'negative account balance' on a read-only endpoint. Your validator should also check that the action described in the When step is actually possible given the system boundary; a simple allowlist of valid operations per boundary can catch many of these errors before they waste engineering time.
Expected Output Contract
Defines the required fields, types, and validation rules for each negative Gherkin scenario generated by the prompt. Use this contract to build a post-processing validator or to configure structured output modes.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
scenario_id | string (kebab-case) | Must match pattern ^neg-[a-z0-9-]+$ and be unique within the generated set | |
scenario_name | string | Must start with a negative outcome keyword (e.g., 'Should reject', 'Must deny', 'Fails when') and be under 120 characters | |
traceability_tag | string | Must map to exactly one happy-path scenario ID or requirement ID provided in [HAPPY_PATH_IDS]; parse check against input list | |
boundary_or_constraint | string | Must reference a specific system boundary, validation rule, or resource limit from [SYSTEM_CONSTRAINTS]; null not allowed | |
gherkin_steps | array of strings | Array must contain at least one Given, one When, and one Then step; each step must start with a valid Gherkin keyword | |
expected_error_code | string or null | If provided, must match a code from [ERROR_CODE_CATALOG]; if null, the scenario must describe a system-level failure (e.g., timeout, crash) | |
invalid_input_payload | object or null | If the scenario involves malformed input, this must be a valid JSON object representing the bad payload; schema check against [API_SCHEMA] to confirm it violates a constraint | |
cleanup_step | string | If the scenario creates state, this must contain a Gherkin Given or When step to restore the test environment; parse check for Gherkin keyword prefix |
Common Failure Modes
Negative scenario generation fails in predictable ways. Here are the most common failure modes when prompting for unhappy-path Gherkin, and how to guard against them.
Happy-Path Echoing
What to watch: The model rephrases happy-path scenarios with minor negations (e.g., 'Given an invalid email' without specifying what makes it invalid) instead of generating genuinely distinct failure scenarios. This produces shallow coverage that misses boundary conditions, authorization gaps, and dependency failures. Guardrail: Require each negative scenario to cite a specific system boundary or constraint from the source spec. Add a validator that rejects scenarios without an explicit boundary reference.
Missing Precondition Contradiction
What to watch: Generated scenarios place the system in an impossible state—e.g., testing an 'unauthorized access' scenario while the Given step still provisions valid credentials. The scenario becomes untestable because the preconditions don't actually create the failure condition. Guardrail: Add a post-generation check that each Given block explicitly negates or removes the resource, permission, or state required for the happy path. Flag scenarios where the Given block is identical to the corresponding happy-path scenario.
Underspecified Expected Outcomes
What to watch: Then steps use vague language like 'the system should handle the error gracefully' or 'an error should be returned' without specifying the error code, message contract, or observable behavior. This makes the scenario unverifiable in automation. Guardrail: Require each Then step to include at least one of: a specific HTTP status code, a machine-readable error code, a log signal, or a user-visible message pattern. Add a schema check that rejects scenarios with ambiguous outcome language.
Boundary Category Collapse
What to watch: The model generates multiple scenarios that all test the same failure category—e.g., three scenarios for missing required fields but none for authorization failures, timeout behavior, or resource exhaustion. This creates a false sense of coverage. Guardrail: Define a required failure-category checklist (validation, auth, timeout, concurrency, dependency, resource) and prompt the model to produce at least one scenario per category. Validate output against the checklist before accepting.
Dependency Failure Blindness
What to watch: Negative scenarios focus exclusively on input validation and ignore external dependency failures—database unavailability, third-party API timeouts, message queue backpressure, or cache misses. These are the failures most likely to cause production incidents. Guardrail: Explicitly list the system's external dependencies in the prompt context and require at least one negative scenario per dependency failure mode. Use a dependency-inventory check in evaluation.
Concurrency and Ordering Gaps
What to watch: Generated scenarios assume sequential execution and miss race conditions, duplicate submissions, out-of-order events, or stale-state problems. These failures are common in distributed systems but absent from most negative scenario sets. Guardrail: Prompt for at least one scenario covering concurrent requests, one covering duplicate submissions, and one covering stale or out-of-order data. Validate that the output includes explicit isolation or ordering expectations in the Then block.
Evaluation Rubric
Use this rubric to evaluate the quality of negative Gherkin scenarios generated by the prompt. Each criterion should be checked before accepting the output into a test suite.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
System Boundary Mapping | Every negative scenario explicitly references a specific system boundary or constraint from the source acceptance criteria | Scenarios describe generic errors (e.g., 'system fails') without naming the boundary, API, or constraint being violated | Manual review: for each scenario, identify the boundary from the source spec and verify it appears in the scenario steps or comments |
Invalid Input Coverage | At least one scenario per input field type covers: null, empty, boundary-exceeding, type-mismatch, and injection attempts | Only happy-path variations appear; missing null or empty-string cases for required fields; no injection or encoding-mutation inputs | Schema check: parse all input values in the Gherkin examples tables and verify type, length, and format against the source spec constraints |
Authorization Failure Scenarios | Scenarios cover unauthenticated access, insufficient role, cross-tenant access, and expired or revoked credentials where applicable | All negative scenarios assume valid authentication; no scenarios test what happens when the principal lacks the required permission | Coverage check: cross-reference the source spec's actor or role declarations against the generated scenarios' Given preconditions |
Dependency Failure Simulation | Scenarios include timeout, connection refused, malformed response, and slow-response (near-timeout) for each external dependency | Dependency failures are omitted or only covered by a single 'service is down' scenario without distinguishing failure modes | Traceability check: list all external dependencies from the source spec and verify each has at least one scenario per failure mode |
Resource Exhaustion Handling | Scenarios cover rate limiting, quota exceeded, concurrent request saturation, and payload size limits where applicable | No scenarios test what happens when a resource limit is hit; only functional error paths are covered | Boundary check: identify numeric limits, rate limits, and size constraints in the source spec and verify corresponding exhaustion scenarios exist |
Expected Error Contract Adherence | Every negative scenario includes a Then step specifying the exact error code, message pattern, or observable behavior expected | Scenarios end with 'Then an error occurs' without specifying the error type, code, or user-visible signal | Schema check: extract all Then steps and verify each contains a concrete error identifier, status code, or message pattern |
No Hallucinated Constraints | All tested constraints, boundaries, and error conditions are traceable to the source acceptance criteria or system spec | Scenarios test constraints not present in the source material, such as invented rate limits, fictional roles, or non-existent fields | Citation check: for each scenario's precondition or boundary, require a pointer to the source spec line or section that defines it |
Scenario Isolation and Reproducibility | Each scenario sets up its own preconditions and does not depend on state from another scenario to fail predictably | Scenarios assume prior test state, share mutable data, or have ordering dependencies that prevent independent execution | Parse check: verify each scenario's Given steps fully define the starting state without references to 'previous scenario' or 'existing data' |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a single happy-path Gherkin scenario as [INPUT]. Remove strict output schema requirements. Accept plain text scenario lists instead of structured JSON. Focus on generating 5-10 negative scenarios quickly for review.
Prompt modification
Replace [OUTPUT_SCHEMA] with: "Return a numbered list of Gherkin scenarios. Each scenario must include a comment explaining which system boundary or constraint it targets."
Watch for
- Scenarios that describe impossible states rather than boundary violations
- Missing preconditions that make scenarios untestable
- Overlap between negative scenarios instead of distinct failure modes

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us