CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/gherkin-from-stories

Converts requirements in any input shape into Gherkin scenarios - a user story ("As a … I want … so that …"), a signed-off acceptance-criteria list (ATDD: @AC-N-tagged scenarios, NotImplementedError step stubs, AC-to-test traceability table), existing manual test steps (declarative rewrite that strips UI mechanics), or a raw spec / PRD section (acceptance-criteria extraction with Gherkin or plain-list output). Maps criteria to Scenario blocks, detects Scenario Outline opportunities, factors shared Background, reuses the curated step library, and flags implicit preconditions instead of fabricating them. Emits Gherkin (plus stubs in ATDD mode): runner detection and full step wiring belong to bdd-scenario-author. Use whenever requirements text of any shape needs to become a .feature file.

70

Quality

88%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

manual-step-rules.mdreferences/

Manual test steps to declarative Gherkin - classification and rewrite rules

Deep reference for gherkin-from-stories ("from manual test steps" input shape). Consult when migrating manual scripts (TestRail / Qase / Xray exports) to BDD or handing a manual script to an automation engineer.

A manual test script and a Gherkin scenario describe the same behavior at different abstraction levels. Manual scripts are imperative ("click the Add to Cart button, then verify the cart count is 1"); Gherkin steps should be declarative ("the customer adds a product to their cart, then their cart shows one item"). The conversion goes wrong in a predictable way: one-for-one translation of UI mechanics produces brittle, implementation-coupled scenarios that Cucumber's own guidance warns against (https://cucumber.io/docs/bdd/better-gherkin/).

Step 1 - Classify each manual step

TagPatternExample
UI mechanicVerbs like "click", "tap", "type", "press", "select from dropdown", "navigate to", "scroll" combined with a UI element."Click the Add to Cart button"
State assertion"Verify", "check", "confirm", "ensure" combined with an observable property."Verify the cart count is 1"
Business actionA domain-level verb already (signs in, places order, cancels subscription)."User signs in with valid credentials"
Setup / precondition"Given that…", "Assuming…", "Pre-requisite:"."Given the user is logged in"
Observation / data inspection"Note the order ID for later use", "record the timestamp"."Capture the response time"

UI mechanics and state assertions are the two types to rewrite. Business actions are already declarative - pass them through. Setup converts to Given. Observations are typically dropped from Gherkin and lifted into step-definition implementation details.

Step 2 - Declarative-rewrite rules

The test for whether a step is too imperative: would the wording need to change if the implementation changed (e.g., the UI moved from a button to a voice command)? If yes, rewrite (https://cucumber.io/docs/bdd/better-gherkin/).

Rule R1 - Remove UI mechanics

ImperativeDeclarative
"Click the Add to Cart button""the customer adds a product to their cart"
"Type user@example.com in the email field""the customer signs in as user@example.com"
"Press the Submit button""the customer submits the form"
"Select USA from the country dropdown""the customer chooses USA as their country"
"Scroll to the bottom of the page"(drop - implementation detail; Gherkin should not require it)

Rule R2 - Collapse multi-step UI sequences into one business action

A manual script that says "type email; type password; click Submit" becomes one Gherkin step: When the customer signs in with valid credentials. The business action is "signing in", not "clicking, typing, clicking". The mechanics live in the step definition.

Rule R3 - Replace UI properties with observable outcomes

ImperativeDeclarative
"Verify the cart count is 1""their cart contains one item"
"Confirm the Submit button is disabled""the form cannot be submitted"
"Check that the URL is /dashboard""the customer is on the dashboard"
"Verify that the green checkmark appears""the operation is confirmed"

Rule R4 - Choose the right keyword

Manual step intentGherkin keyword
Setup state that exists before the user acts in this scenarioGiven
The user (or system) takes an action under testWhen
An observable consequence is assertedThen
Add detail to a previous step (same keyword type)And
Negate / contrast a previous stepBut

And and But inherit the type of the previous keyword - they are not interchangeable with Given/When/Then (https://cucumber.io/docs/gherkin/reference/).

Rule R5 - Preserve the project's existing vocabulary

Before emitting the rewrite, scan the project's existing Gherkin for the same business action. If "the customer signs in" is already used, do not introduce "the user logs in" - vocabulary drift fragments the step library and forces step-definition duplication. bdd-step-library-curator audits and consolidates that vocabulary.

Step 3 - Emit a side-by-side rewrite table

Output is a markdown table so a reviewer can confirm semantic equivalence:

Manual step (input)Gherkin step (output)KeywordJustification
Click the Add to Cart button on the SKU-001 product pagethe customer adds SKU-001 to their cartWhenR1 strips UI mechanic; business action elevated
Verify the cart count is 1their cart contains one itemThenR3 swaps UI property for observable outcome
Type email; type password; click Submitthe customer signs in as user@example.comWhenR2 collapses three UI mechanics to one business action
Pre-requisite: User is logged inthe customer is signed inGivenR4 chooses Given for setup
Note the order ID(dropped - implementation detail)-Out-of-scope for Gherkin per R1

The surviving rows assemble into a Scenario:

Scenario: Customer adds an in-stock product to their cart
  Given the customer is signed in
  When the customer adds SKU-001 to their cart
  Then their cart contains one item

Step 4 - Validate against project conventions

  1. Check the project step library for matching existing steps; flag new steps for bdd-step-library-curator review.
  2. Confirm the scenario has at most one When. Multiple Whens indicate two scenarios were collapsed; split them.
  3. Lint with the project's Gherkin linter (gherkin-lint, picklesdoc, or the IDE's built-in).
  4. Diff the rewrite against the manual step's expected outcome - semantic equivalence is the bar. If the manual step asserts "cart count is 1" but the rewrite asserts "cart is non-empty", that is a regression in specificity, not a successful abstraction.

Migration-specific anti-patterns

Anti-patternWhy it failsFix
One-for-one translation that keeps "the customer clicks the button"Brittle to UI changes; Cucumber explicitly warns against itApply R1 strictly
Multiple Whens in one scenario after collapsingThe scenario contains two business actionsSplit into two scenarios
Inventing new vocabulary when matching steps existVocabulary drift; duplicate step definitionsCross-reference the existing library (R5)
Dropping all Then assertions because they "look like UI checks"The scenario becomes unverifiableR3 rewrites assertions; doesn't drop them
Translating every UI mechanic, including business-relevant ones"Selects USA as country" may be load-bearing; "scrolls to footer" is notPreserve domain-meaningful selections
Gherkin that needs a comment to explainThe rewrite is wrongMake the scenario self-explanatory

Migration-specific limitations

  • Vocabulary alignment is the bottleneck, not translation. For large projects, run bdd-step-library-curator first to canonicalize vocabulary.
  • Some manual steps are inherently UI-mechanical. A11y tests asserting "the Skip to main link is the first focusable element" cannot be rewritten into business language without losing the spec - pass through with R1 disabled and tag @a11y for the team to decide.
  • Numerical specificity is preserved, not abstracted. "Cart count is 1" stays "cart contains one item" - not "cart is non-empty".
  • Output is a draft. A human reviews the side-by-side before merging.

Sources

SKILL.md

tile.json