Deprecate `And` and `But` functions for step definitions
See original GitHub issueCurrent behavior
Step definitions can be defined with Given
, When
, Then
, And
and But
- see https://github.com/badeball/cypress-cucumber-preprocessor/blob/b6295672f0433f454b14c2ea3f7f859a97f0ac44/lib/index.ts#L65-L71
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
- I’ve read the FAQ.
- I’ve read Instructions for logging issues.
- I’m not using
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).
Issue Analytics
- State:
- Created a year ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
How to document cucumber js step definitions with JsDoc
Deprecating step definitions This approach allows you to have a step definition that is being used by a scenario feature, but you...
Read more >Calling Steps from Step Definitions - SpecFlow's documentation
It is possible to call steps from within Step Definitions: [Binding] public class CallingStepsFromStepDefinitionSteps : Steps { [Given(@"the user (.
Read more >Reuse Cucumber steps - Stack Overflow
UPDATE: The method described below has been deprecated. ... Calling steps from step definitions is a bad practice and has some disadvantages ...
Read more >State - Cucumber Documentation
Within your scenarios, you might want to share state between steps. It's possible to store object state in variables inside your step definitions....
Read more >Step Definition - Cucumber - Tools QA
What is Step Definition in Cucumber, How to create Step Definition file in ... it executes the piece of code written inside the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@iomedico-beyer can you give me a concrete example of a sentence/step that would be different with
Dann
andUnd
? I’m one of the maintainers of Cucumber and understanding this would be helpful.I want to highlight the following comment from Mar 16, 2021: https://github.com/cucumber/cucumber-js/issues/1615#issuecomment-800401681