Skip to content

[Feature Request] Support "Background" keyword in Gherkin output #6

@Kahoulam

Description

@Kahoulam

Description

Currently, bdd_framework does not provide a way to define or export the Background keyword in Gherkin. When multiple scenarios share the same initial steps, they have to be repeated in every scenario, which leads to bloated .feature files.

Current Behavior

Even if I repeat the same Given steps in every Bdd instance, the GherkinExporter prints them inside each Scenario.

Requested Feature

I would like a way to explicitly define common steps for a BddFeature so that the exporter can group them under a Background: section.

Example of how it might look in code:

var feature = BddFeature('User Login');

// New proposed method to define background
Bdd.background(feature)
  .given('the app is open')
  .and('the user is on the login page');

Bdd(feature)
  .scenario('Success')
  .when('...')
  .then('...');

Expected Gherkin Output:

Feature: User Login

  Background:
    Given the app is open
    And the user is on the login page

  Scenario: Success
    When ...
    Then ...

Why this is needed

To comply with standard Gherkin formatting and to keep exported feature files clean and readable for non-technical stakeholders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions