org.jbehave.core.steps
Class Steps

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

public class Steps
extends java.lang.Object
implements CandidateSteps

Default implementation of CandidateSteps which provides access to the model of candidate steps that match the core 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 core model 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(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 annotated steps methods
 
Method Summary
protected  CandidateStep createCandidateStep(java.lang.reflect.Method method, StepType stepType, java.lang.String stepPatternAsString, int priority, StepsConfiguration configuration)
           
 StepsConfiguration getConfiguration()
          Returns the steps 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 core
 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 core
 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(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 annotated 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

getConfiguration

public StepsConfiguration getConfiguration()
Description copied from interface: CandidateSteps
Returns the steps configuration

Specified by:
getConfiguration in interface CandidateSteps
Returns:
The StepsConfiguration

runBeforeScenario

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

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 core

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.