Class Steps

All Implemented Interfaces:
CandidateSteps

public class Steps extends AbstractCandidateSteps

Default implementation of CandidateSteps which provides the step candidates that match the steps being run.

To provide your step candidate methods, you can:

  • pass in the steps instance type and the steps factory used to instantiate the instance if any candidate steps are matched (lazy "has-a" relationship)
  • pass in the steps instance, instantiated regardless of whether the candidate steps are matched (eager "has-a" relationship)
  • extend the Steps class, in which case the instance is the extended Steps class itself ("is-a" relationship)
The "has-a" design model, in which the steps instance is passed in, is strongly recommended over the "is-a" model as it does not have tie-ins in the Steps class implementation.

You can define the methods that should be run by annotating them with @Given, @When or @Then, and providing as a value for each annotation a pattern matches the textual step. The value is interpreted by the StepPatternParser, which by default is a RegexPrefixCapturingPatternParser that interprets the words starting with '$' as parameters.

For instance, you could define a method as:

 @When("I log in as $username with password: $password")
 public void logIn(String username, String password) { //... }
 
 
and this would match the step:
 When I log in as Liz with password: Pa55word
 

When the step is performed, the parameters matched will be passed to the method, so in this case the effect will be to invoke:

 logIn("Liz", "Pa55word");
 

The Configuration can be used to provide customize the StepCandidates that are created, e.g. providing a step monitor or creating them in "dry run" mode.

  • Constructor Details

    • Steps

      public Steps()
      Creates Steps with default configuration for a class extending this instance and containing the candidate step methods
    • Steps

      public Steps(Configuration configuration)
      Creates Steps with given custom configuration for a class extending this instance and containing the candidate step methods
      Parameters:
      configuration - the Configuration
    • Steps

      public Steps(Configuration configuration, Object instance)
      Creates Steps with given custom configuration and a steps instance containing the candidate step methods
      Parameters:
      configuration - the Configuration
      instance - the steps instance
    • Steps

      public Steps(Configuration configuration, Class<?> type, InjectableStepsFactory stepsFactory)
      Creates Steps with given custom configuration and a steps instance type containing the candidate step methods. The steps instance is created using the steps instance factory provided.
      Parameters:
      configuration - the Configuration
      type - the steps instance type
      stepsFactory - the InjectableStepsFactory
  • Method Details