BDD / Gherkin

AI Prompt to Generate BDD Gherkin Scenarios

Good Gherkin describes behaviour in business language; bad Gherkin is a click-by-click script. This prompt pushes the AI toward declarative scenarios, reusable steps, and Scenario Outlines for data variations.

The prompt

You are a BDD practitioner writing Gherkin for a Cucumber suite.

Feature / requirement:
[PASTE REQUIREMENT OR USER STORY]

Business rules:
[LIST RULES]

Existing step phrases to reuse (optional):
[PASTE STEPS]

Write a .feature file that:
1. Has a Feature title and a short "In order to / As a / I want" description.
2. Uses a Background only for steps shared by every scenario.
3. Writes declarative steps in business language (what, not how). No CSS selectors, URLs, or UI clicks like "I click the blue button".
4. Has one behaviour per scenario, with a single When where possible.
5. Uses Scenario Outline + Examples for data-driven variations, including invalid values.
6. Covers the happy path, rule violations, and at least one edge case.
7. Adds tags like @smoke, @regression, @negative.

After the file, list any rule that was ambiguous as a question for the team.

Replace every [BRACKETED] placeholder with your own details.

Sample input: password reset

Fictional example written for this guide.

Requirement: Users can reset a forgotten password via an emailed link.
Rules:
- The link expires after 30 minutes.
- The link can be used only once.
- New password: 8–64 characters, at least one number and one letter.
- The new password cannot equal the current password.

Sample AI output (illustrative)

Sample output only — this shows the shape of a good answer. It has not been run, executed, or verified against a real system.

@password-reset
Feature: Reset a forgotten password
  In order to regain access to my account
  As a registered user
  I want to set a new password using an emailed link

  Background:
    Given a registered user "maya@example.test" has requested a password reset

  @smoke
  Scenario: Reset password with a valid link
    When she sets a new password "Garden2026" using the reset link
    Then she can sign in with "Garden2026"
    And the reset link can no longer be used

  @negative
  Scenario: Expired reset link is rejected
    Given the reset link was issued 31 minutes ago
    When she tries to set a new password using the reset link
    Then she is told the link has expired
    And her password is unchanged

  @negative @regression
  Scenario Outline: New password must meet the rules
    When she sets a new password "<password>" using the reset link
    Then she sees the message "<message>"

    Examples:
      | password       | message                                   |
      | short1         | Password must be at least 8 characters    |
      | onlyletters    | Password must include a number            |
      | 12345678       | Password must include a letter            |
      | CurrentPass1   | New password must differ from the current |

Questions for the team
- Is 64 characters an inclusive upper limit?
- Does requesting a second link invalidate the first?

Imperative vs. declarative: what to fix

If the AI produces the first style, ask it to rewrite in the second.

# Imperative (avoid)
When I click "Forgot password"
And I type "maya@example.test" into the email field
And I click the "Send" button

# Declarative (prefer)
When Maya requests a password reset

Review tips for generated Gherkin

  • Each scenario should test one behaviour — split scenarios with multiple Whens.
  • Then steps must be observable outcomes, not internal state.
  • Reuse existing step phrases so you are not writing new step definitions for synonyms.
  • Keep Examples tables small and meaningful; each row should test a different rule.
  • Read scenarios aloud with a product owner — if they can't follow it, simplify.

QA review before you use the output

  • • Check every message string and limit against the real requirement before automating.
  • • Generated scenarios are a draft — step definitions still have to be written and run.
  • • Use fictional names and example.test emails; never paste production user data.
  • • AI output can be wrong or incomplete. A human tester owns the final result.

Related prompts

Need a different QA prompt?

Browse 50+ copy-ready prompts or build your own in seconds.