question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow Scenario reuse

See original GitHub issue

I would like to reuse step definitions grouped to a scenario. This is particularly useful, if TDD strategy is used for incremental tests development along a happy path. In doing so, the scenarios follow the pattern below:

Feature HappyPath
Scenario X
  Given A
  When B
  Then C

Scenaro X+1
  Given A
    And B
  When C
  Then D

Scenaro X+2
  Given A
    And B
    And C
  When D
  Then E

and so on. I would like to reuse the information already stated in the previous scenario. In order to do so, we can rewrite the previous feature HappyPath in the following way:

Feature HappyPath
Scenario X
  Given A
  When B
  Then C

Scenario X+1
  Given "Scenario X"
  When "Scenario X" 
    And C
  Then D

Scenario X+2
  Given "Scenario X+1"
  When "Scenario X+1"
    And D 
  Then E

The meaning of Given “Scenario X” is to execute all steps from Scenario X annotated with Given, When “Scenario X” will execute all When steps from the Scenario X and Then “Scenario X” is responsible for running all Then steps from the scenario.

This addition will allow getting a much higher reuse of Gherkin definitions and steps from the glue classes. In particular, fosters the reuse of parameters used in steps and reduces duplication.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

0reactions
lock[bot]commented, Aug 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I reuse my gherkin scenarios? - John Ferguson Smart
The answer is, we should never need to. Reuse happens under the hood, in the step definitions. Steps like "And Carlos is on...
Read more >
Can we reuse a scenario in cucumber - Stack Overflow
I am working in protractor-cucumber framework.In our requirement,one section is common in all part.Let say creating a post in 10 locations.
Read more >
How to call one scenario from another? Embrace Shared Steps
Reusing parts of scenarios (or entire scenarios) is a common feature of test management tools, and people coming to Given-When-Then specs from a...
Read more >
Embedding and reusing scenario tests - Pega
You can record a scenario test and save it as a reusable component to embed in one or more scenario tests. Reusing scenario...
Read more >
How to not repeat yourself in Cucumber scenarios
When you reuse behavior you want to reuse tests as well. ... many different ways to share code between Cucumber scenarios, allowing you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found