Step methods

Finally, every step is associated with a step method. A step method is a Gosu method that maps a scenario step to a method in a specific interface.

Step methods are declared inside step classes. Every step class injects Context Factory. Therefore, every step method has access to all of the context API interfaces. And, because RemoteSmokeTestHelperModule binds every interface to one or more impls, the step method can name the method to implement.

For example, the following code is a step method from the AdminSteps class.

@Given("^I am a user with the \"([^\"]*)\" role$")
function createUserWithRoleAndSetAsCurrentUser(roleString: String) {
  _contextFactory.getAdminContext().createAndSetUserWithRole(roleString)
}

The step method is: createUserWithRoleAndSetAsCurrentUser. It maps the "I am a user with the "X" role" step to the createAndSetUserWithRole method from the AdminContext interface. (RemoteSmokeTestHelperModule maps this interface to the AdminContextImpl impl.)


The path from a scenario step to the impl code that implements the step.

The remainder of this topic discusses step methods in detail. For information on when and how to modify Context Factory and RemoteSmokeTestHelperModule, see: