Skip to content

Deprecate And and But functions for step definitions #821

@aslakhellesoy

Description

@aslakhellesoy

Current behavior

Step definitions can be defined with Given, When, Then, And and But - see

export {
defineStep as Given,
defineStep as When,
defineStep as Then,
defineStep as And,
defineStep as But,
};

Desired behavior

Step definitions can be defined with Given, When and Then. This is what Cucumber.js does: https://github.com/cucumber/cucumber-js/blob/01368ca6e3c9b097a7a88bb72de5beeddb4a0326/src/index.ts#L45-L51

Here is an example illustrating why:

Feature: banking
  Scenario: Overdraft
    Given I have an overdraft limit of 50
    And I have a balance of 300
    When I withdraw 330
    Then my balance should be -30

With the currentl API, people might implement step definitions this way:

Given('I have an overdraft limit of {int}')
And('I have a balance of {int}')

But what if I add a new scenario:

  Scenario: No overdraft
    Given I have a balance of 300
    When I withdraw 330
    Then my balance should be 300
    And I should be told my overdraft limit is 0

It no longer makes sense that the step defnition is defined with And.

The And and But keywords only belong in Gherkin. Step definitions are reusable in any order, and should therefore not use And and But.

Checklist

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