Gherkin Generator

Turn a user story and acceptance criteria into a valid .feature file.

As a <role>, I want <capability>, so that <benefit>.

Given-steps that run before every scenario.

Each scenario is a concrete, testable example.

Before you export

  • Use one scenario per behavior, not one giant scenario for the whole feature.
  • Keep Given steps about state, When steps about action, and Then steps about observable results.
  • Remove implementation details that a user or test runner cannot observe.
feature.feature

What this tool actually produces

Review-ready Markdown

The generator output is meant to be pasted into a ticket, pull request, or design review. It should name the owner, decision, evidence, and follow-up work before implementation starts.

Feature: Refund retry protection

Scenario: duplicate refund request
  Given a refund is pending provider confirmation
  When support submits the same refund again
  Then the existing refund_id is returned
  And no second provider call is made

After export

Treat the generated Gherkin feature file as a starting artifact. Replace example values, attach evidence, assign reviewers, and remove sections your team will not maintain.

  • Keep the output next to the implementation work.
  • Map every acceptance item to test or review evidence.
  • Do not paste secrets, customer data, or private incident details.

Gherkin at a glance

Gherkin is a plain-language syntax for describing software behavior. Feature states what you're testing, Scenario describes a concrete case, and Given / When / Then structures the precondition, action, and expected result. Cucumber, Behat, SpecFlow and similar frameworks parse .feature files directly.

Related: Acceptance Criteria Examples, Given/When/Then Template.

How to write useful Gherkin

Write behavior, not UI choreography

A good scenario says what state exists, what the actor does, and what result must be true. Avoid brittle steps such as "click the blue button in the upper right" unless the UI itself is the behavior under test.

Keep scenarios independent

Every scenario should be understandable on its own. If one scenario needs another scenario to run first, move that shared state into Background or split the feature file.

Prefer examples over abstractions

"Invalid login fails" is vague. "Wrong password returns a visible error and does not create a session" is testable. Use concrete data when it clarifies the expected behavior.

Map Gherkin back to acceptance criteria

Each generated scenario should trace to a requirement in your spec. If a scenario does not protect a real user, API, or business rule, it may be noise.

Weak vs strong scenario

Weak

Scenario: Reset password
Given I am on the page
When I submit the form
Then it works

This scenario does not say which user state exists, what input is submitted, or what result proves the reset flow worked.

Strong

Scenario: User requests a reset link
Given a verified user exists for [email protected]
When she requests a password reset
Then a single-use reset email is queued

This version describes state, action, and observable output. It is specific enough for QA, automation, and implementation review.

When not to use Gherkin

Pure technical constraints

Algorithm complexity, cache strategy, database index selection, and internal service topology are often clearer as unit tests, performance tests, migration checks, or design notes.

Still-unsettled requirements

If the team has not agreed on user behavior and business outcome, write a normal spec or decision note first. Gherkin too early can make unresolved questions look test-ready.

Overly detailed UI scripts

If the scenario mostly says where to click, scroll, or type, maintenance cost will be high. Move the step up to user intent and observable result unless UI choreography is the feature.

How to bring generated Gherkin into a team workflow

Review language before automation

Take the generated scenarios to product, engineering, and QA first. Confirm the actors, states, and outcomes use the same business language before connecting them to a test runner.

Automate the highest-value scenarios

Not every generated scenario belongs in end-to-end automation. Prioritize the core workflow, permission boundaries, expensive failures, and cases that have caused regressions before.

What to do after export

Review step language with QA

Before wiring scenarios to automation, ask QA whether each step can be verified without private implementation knowledge. If a step requires reading logs or database internals, rewrite the expected result as observable behavior.

Keep fixtures close to scenarios

Generated Gherkin is easier to maintain when the required user state, seed data, permissions, and feature flags are documented near the feature file instead of hidden in a shared test setup.

Delete stale scenarios aggressively

When product behavior changes, update or remove scenarios in the same pull request. Old feature files that describe retired behavior create false confidence and make future refactors slower.

What a finished feature file should prove

The scenario protects behavior

Each scenario should protect a real user outcome, permission boundary, API contract, or regression risk. If it only describes clicking through the interface, it may be a brittle script rather than a useful specification.

The result is observable

A reviewer should be able to point to the UI state, response body, emitted event, database-visible state, or audit record that proves the Then step passed.

How to use the export in review

Review examples with QA before automation

Read the exported scenarios as a shared behavior document before turning them into automated tests. If QA cannot identify the fixture, action, and expected assertion from a scenario, improve the wording before implementation depends on it.

Keep business language stable

Use the same domain terms in the feature file, spec, UI copy, and support documentation. Gherkin loses value when each team invents a slightly different name for the same state or role.

Gherkin FAQ

Should every acceptance criterion become Gherkin?

Not always. Use Gherkin for behavior that benefits from executable examples or shared product language. Some technical constraints are clearer as unit tests, API contract tests, or migration checks.

How many scenarios should a feature file contain?

Enough to cover the meaningful behavior: happy path, important failure path, permission boundary, and one or two edge cases. If the file becomes hard to scan, split it by workflow.

How this tool was designed and reviewed

Built for executable behavior

The form pushes scenarios toward clear state, action, and observable result. It is designed to avoid vague acceptance criteria that read well in a ticket but cannot become a useful test.

Reviewed for shared language

Generated scenarios are judged by whether product, QA, and engineering can read the same feature file and agree on fixture setup, user action, expected result, and business wording.