Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Calling Steps from StepDefinitions

aslakhellesoy edited this page May 25, 2011 · 4 revisions

In Cucumber on Ruby you can Call Steps from StepDefinitions

This is possible in Cuke4Duke too, but currently only if you’re using Java or Scala Step Definitions.

Java

Just make sure your Step Definition class inherits from cuke4duke.Steps, and make sure its constructor takes a cuke4duke.StepMother in the constructor. Example:

public class CallingSteps extends Steps {
    public CallingSteps(StepMother stepMother) {
        super(stepMother);
    }

    @When("^I call another step$")
    public void iCallAnotherStep() {
        Given("it is magic"); // This will call a step defined somewhere else.
    }
}

Scala

In Scala things are a little simpler:

class CallingSteps extends ScalaDsl {
  When("^I call another step$") { () =>
    Given("it is magic")
  }
}
Clone this wiki locally