Skip to content

Matthew-M-King/RobotFrameworkToCucumberConverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

RobotFrameworkToGherkin

A utility to convert Robot Framework test suites into Gherkin-style .feature files, making it easy to migrate or document your tests for use with BDD tools like Cucumber, Behave, or SpecFlow.

Features

  • Converts .robot test suites to .feature files
  • Preserves:
    • Test case names as Scenario: blocks
    • Robot tags as Gherkin @tags
    • Test steps in Given / When / Then / And format
    • Suite-level documentation as the Feature: name
    • Setup and teardown keywords (as optional steps)
  • Supports nested test suites and structured keywords
  • CLI and programmatic usage

Example

✅ Example

Input (basket.robot)

*** Settings ***
Documentation     Basket
...               Tests related to basket (cart) of selected products
Resource          ../Resources/Setup.robot
Suite Setup       Setup Suite
Suite Teardown    Teardown Suite
Test Setup        Start At ProductInventory Page
Test Teardown     Teardown Test
Test Tags         basket

*** Test Cases ***
User can view a summary with a single product in the basket
    [Tags]    smoke    regression
    Given there are minimum products in the basket
    When user views the basket contents
    Then all the selected products should be listed
    And the product details should be correct

Output (Basket.feature)

Feature: Basket
  Tests related to basket (cart) of selected products

  @basket @smoke @regression
  Scenario: User can view a summary with a single product in the basket
    Given there are minimum products in the basket
    When user views the basket contents
    Then all the selected products should be listed
    And the product details should be correct

Usage

Command Line Interface

python bdd_converter.py path/to/tests.robot output/
  • path/to/tests.robot: Path to your Robot Framework test file or directory
  • output/: Output directory for .feature files

Optional: specify a custom title for the feature

python bdd_converter.py path/to/tests.robot output/ --title "Basket"

Programmatic Usage

from bdd_converter import bdd_converter

bdd_converter('tests/my_suite.robot', 'output/')

Output Structure

Each Robot test suite is converted into a .feature file named after the suite:

output/
└── Basket.feature

Notes

  • Tags from both suite and individual test cases are included as @tags
  • Setup and teardown steps can be optionally shown
  • Control structures like FOR, IF, and TRY are supported
  • All keyword arguments are preserved as plain text for readability

Roadmap

  • Add step type inference (e.g. auto-prefix with Given/When/Then)
  • CLI option to exclude teardown/setup
  • HTML report showing original Robot steps and converted Gherkin

License

MIT License

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.

Author

Created by Matthew King – Test Automation Engineer

About

Convert Robot Framework test cases to Gherkin .feature files for BDD compatibility

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages