Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nested step functionality #223

Closed
wants to merge 1 commit into from
Closed

Add nested step functionality #223

wants to merge 1 commit into from

Conversation

cono
Copy link

@cono cono commented Aug 13, 2014

I wanted to add nested step functionality like ruby version has:
https://github.com/cucumber/cucumber/wiki/Calling-Steps-from-Step-Definitions

Can be used like so:
feature file:

Feature: Nested Steps

  Scenario: Simple step
    Given a turtle

  Scenario: Use World.step to call a single step
    Given two turtles

step definition:

var cucumberStepsTests = function() {
  var Given  = When = Then = this.defineStep;
  var World  = require('./cucumber_world').World;
  this.World = World;

  Given(/^a turtle$/, function(callback) {
    console.log('turtle!');
    callback();
  });

  Given(/^two turtles$/, function(callback) {
      var World = this;
    World.step("a turtle", function() {
        World.step("a turtle", function() {
            callback();
        });
    });
  });
};

module.exports = cucumberStepsTests;

Please share your thoughts.

@aslakhellesoy
Copy link
Contributor

-1

I consider calling steps from stepdefs an antipattern. If you want to reuse code, regular functions is much better.

@jbpros
Copy link
Member

jbpros commented Aug 13, 2014

Thanks @cono for the PR. However, as has been discussed before this will not be implemented in Cucumber.js.

@jbpros jbpros closed this Aug 13, 2014
@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants