How to use the Cucumber Step Definition Generator
- 1. Paste the featureAny Gherkin with Given, When, Then, And and But, including Scenario Outlines.
- 2. Pick a languageJava (cucumber-java), JavaScript (@cucumber/cucumber) or Python (behave).
- 3. GenerateCopy the step definitions and fill in each TODO.
How steps become definitions
Each step's text becomes a Cucumber Expression. Quoted text becomes {string}, whole numbers {int} and decimals {float}. For Scenario Outlines, the tool looks at the Examples table: a <seats> placeholder whose values are all whole numbers becomes {int}, and single words become {word}. Steps that differ only in their values share one definition, And and But steps take the keyword of the step before them, and steps followed by a table or doc string get a DataTable or doc string argument. Everything runs in your browser; nothing you enter is uploaded.
For Python, the expressions are converted to behave's parse format, such as "{text}" and {number:d}.
Worked example
The sample enrolment feature has 3 scenarios, including an outline and a data table. The tool finds 9 unique steps; I should see "…" appears in two scenarios but needs only one definition. the course "<course>" has <seats> seats left becomes the course {string} has {int} seats left. A dry run with cucumber-js and with behave found every step defined, and the Java version compiles.
Tips
- Write steps in business language ("I enrol"), not UI clicks ("I click the blue button").
- Reuse step wording across features so definitions stay few.
- Keep assertions in Then steps only.
Frequently asked questions
Why are definitions pending?
Each one throws PendingException (or returns 'pending'), so Cucumber reports them as pending until you add the real code.
Does it support Rule and Background?
Yes. Their steps are included like any other; Rule and Background headings themselves need no code.
Is the Cucumber step generator free?
Yes. You can open the Cucumber step generator and fill in everything without signing up. When you generate step definitions for the first time, we ask once for your name and WhatsApp number; after that it, and every other Uncodemy tool, opens straight away.