org.jbehave.scenario.steps
Class Steps

java.lang.Object
  extended by org.jbehave.scenario.steps.Steps
All Implemented Interfaces:
CandidateSteps

public class Steps
extends java.lang.Object
implements CandidateSteps

Extend this class to provide the definition of steps that match the scenario you want to run.

You can define the methods that should be run when each step is performed by annotating them with @Given, @When or @Then, and providing a value for each annotation that matches the step. By default, the match is performed using a '$' prefix to pick up parameters.

For instance, you could define a method as:

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

When the step is perfomed, the parameters in the scenario definition will be passed to the class, so in this case the effect will be

 mySteps.logIn("Liz", "Pa55word");
 

StepsConfiguration can be used to provide customization to the defaults configuration elements, eg custom parameters converters.


Nested Class Summary
static class Steps.DuplicateCandidateStepFoundException
           
 class Steps.SilentStepResult
           
 
Constructor Summary
Steps()
          Creates Steps with default configuration
Steps(ParameterConverters converters)
          Creates Steps with all default dependencies except for custom parameter converters.
Steps(StepsConfiguration configuration)
          Creates Steps with all custom dependencies
Steps(java.lang.String... startingWords)
          Creates Steps with all default configuration except for custom starting keywords
 
Method Summary
 CandidateStep[] getSteps()
          Return all the steps that can be performed by the implementing class
 CandidateStep[] getSteps(java.lang.Class<?> stepsClass)
          Return all the steps that can be performed by the given class
 java.util.List<Step> runAfterScenario()
          Return all steps to run after scenario
 java.util.List<Step> runBeforeScenario()
          Return all steps to run before scenario
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Steps

public Steps()
Creates Steps with default configuration


Steps

public Steps(java.lang.String... startingWords)
Creates Steps with all default configuration except for custom starting keywords

Parameters:
startingWords - the words with which we expect steps in the scenarios to start

Steps

public Steps(ParameterConverters converters)
Creates Steps with all default dependencies except for custom parameter converters.

Parameters:
converters - a set of converters which can change strings into other objects to pass into executable steps

Steps

public Steps(StepsConfiguration configuration)
Creates Steps with all custom dependencies

Parameters:
configuration - the StepsConfiguration
Method Detail

getSteps

public CandidateStep[] getSteps()
Description copied from interface: CandidateSteps
Return all the steps that can be performed by the implementing class

Specified by:
getSteps in interface CandidateSteps
Returns:
The list of candidate steps

getSteps

public CandidateStep[] getSteps(java.lang.Class<?> stepsClass)
Description copied from interface: CandidateSteps
Return all the steps that can be performed by the given class

Specified by:
getSteps in interface CandidateSteps
Returns:
The list of candidate steps

runBeforeScenario

public java.util.List<Step> runBeforeScenario()
Description copied from interface: CandidateSteps
Return all steps to run before scenario

Specified by:
runBeforeScenario in interface CandidateSteps
Returns:
The list of steps

runAfterScenario

public java.util.List<Step> runAfterScenario()
Description copied from interface: CandidateSteps
Return all steps to run after scenario

Specified by:
runAfterScenario in interface CandidateSteps
Returns:
The list of steps


Copyright © 2003-2009. All Rights Reserved.