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

Default implementation of CandidateSteps which provides access to the definition of candidate steps that match the scenario you want to run.

To provide your candidate steps method, you can either extend the Steps class or pass it a POJO instance that it can wrap. In the former case, the instance is the Steps class itself.

You can define the methods that should be run by annotating them with @Given, @When or @Then, and providing a value for each annotation that matches the step. The value is interpreted by the StepPatternBuilder, which by default interprets the '$' as 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(KeyWords keywords)
          Creates Steps with all default configuration except for custom starting keywords
Steps(ParameterConverters converters)
          Creates Steps with all default dependencies except for custom parameter converters.
Steps(StepsConfiguration configuration)
          Creates Steps with given custom configuration
Steps(StepsConfiguration configuration, java.lang.Object instance)
          Creates Steps with given custom configuration wrapping a POJO instance containing the annotatated steps methods
Steps(java.lang.String... startingWords)
          Deprecated. Use Steps(KeyWords)
 
Method Summary
protected  CandidateStep createCandidateStep(java.lang.reflect.Method method, StepType stepType, java.lang.String stepPatternAsString, int priority, StepsConfiguration configuration)
           
 CandidateStep[] getSteps()
          Return all the candidate steps that can be performed by the implementing class
 CandidateStep[] getSteps(java.lang.Class<?> stepsClass)
          Return all the candidate steps that can be performed by the given class
 java.util.List<Step> runAfterScenario()
          Return all the executable steps to run after each scenario
 java.util.List<Step> runAfterStory(boolean embeddedStory)
          Return all the executable steps to run after each story, based on the embedded status
 java.util.List<Step> runBeforeScenario()
          Return all the executable steps to run before each scenario
 java.util.List<Step> runBeforeStory(boolean embeddedStory)
          Return all the executable steps to run before each story, based on the embedded status
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Steps

public Steps()
Creates Steps with default configuration


Steps

public Steps(KeyWords keywords)
Creates Steps with all default configuration except for custom starting keywords

Parameters:
keywords - the KeyWords which hold the words with which we expect steps in the scenarios to start

Steps

public Steps(java.lang.String... startingWords)
Deprecated. Use Steps(KeyWords)

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 given custom configuration

Parameters:
configuration - the StepsConfiguration

Steps

public Steps(StepsConfiguration configuration,
             java.lang.Object instance)
Creates Steps with given custom configuration wrapping a POJO instance containing the annotatated steps methods

Parameters:
configuration - the StepsConfiguration
instance - the POJO instance
Method Detail

getSteps

public CandidateStep[] getSteps()
Description copied from interface: CandidateSteps
Return all the candidate 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 candidate steps that can be performed by the given class

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

createCandidateStep

protected CandidateStep createCandidateStep(java.lang.reflect.Method method,
                                            StepType stepType,
                                            java.lang.String stepPatternAsString,
                                            int priority,
                                            StepsConfiguration configuration)

runBeforeStory

public java.util.List<Step> runBeforeStory(boolean embeddedStory)
Description copied from interface: CandidateSteps
Return all the executable steps to run before each story, based on the embedded status

Specified by:
runBeforeStory in interface CandidateSteps
Parameters:
embeddedStory - the boolean flag denoting the embedded status
Returns:
The list of steps

runAfterStory

public java.util.List<Step> runAfterStory(boolean embeddedStory)
Description copied from interface: CandidateSteps
Return all the executable steps to run after each story, based on the embedded status

Specified by:
runAfterStory in interface CandidateSteps
Parameters:
embeddedStory - the boolean flag denoting the embedded status
Returns:
The list of steps

runBeforeScenario

public java.util.List<Step> runBeforeScenario()
Description copied from interface: CandidateSteps
Return all the executable steps to run before each 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 the executable steps to run after each scenario

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2010. All Rights Reserved.