Class Steps
- java.lang.Object
-
- org.jbehave.core.steps.AbstractCandidateSteps
-
- org.jbehave.core.steps.Steps
-
- All Implemented Interfaces:
CandidateSteps
public class Steps extends AbstractCandidateSteps
Default implementation of
CandidateStepswhich 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
Stepsclass, in which case the instance is the extendedStepsclass itself ("is-a" relationship)
Stepsclass implementation.You can define the methods that should be run by annotating them with
@Given,@Whenor@Then, and providing as a value for each annotation a pattern matches the textual step. The value is interpreted by theStepPatternParser, which by default is aRegexPrefixCapturingPatternParserthat interprets the words starting with '$' as parameters.For instance, you could define a method as:
and this would match the step:@When("I log in as $username with password: $password") public void logIn(String username, String password) { //... }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
Configurationcan be used to provide customize theStepCandidates that are created, e.g. providing a step monitor or creating them in "dry run" mode.
-
-
Constructor Summary
Constructors Constructor Description Steps()Creates Steps with default configuration for a class extending this instance and containing the candidate step methodsSteps(Configuration configuration)Creates Steps with given custom configuration for a class extending this instance and containing the candidate step methodsSteps(Configuration configuration, Class<?> type, InjectableStepsFactory stepsFactory)Creates Steps with given custom configuration and a steps instance type containing the candidate step methods.Steps(Configuration configuration, Object instance)Creates Steps with given custom configuration and a steps instance containing the candidate step methods
-
Method Summary
Modifier and Type Method Description Objectinstance()Map<ScenarioType,List<BeforeOrAfterStep>>listAfterScenario()Returns the after scenario stepsList<BeforeOrAfterStep>listAfterStories()Returns the after stories stepsList<BeforeOrAfterStep>listAfterStory(boolean givenStory)Returns the after story steps, based on the given story statusMap<ScenarioType,List<BeforeOrAfterStep>>listBeforeScenario()Returns the before scenario stepsList<BeforeOrAfterStep>listBeforeStories()Returns the before stories stepsList<BeforeOrAfterStep>listBeforeStory(boolean givenStory)Returns the before story steps, based on the given story statusList<StepCandidate>listCandidates()Returns the step candidates that can be matchedStringtoString()Class<?>type()-
Methods inherited from class org.jbehave.core.steps.AbstractCandidateSteps
configuration, createCandidate
-
-
-
-
Constructor Detail
-
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 Configurationinstance- 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 Configurationtype- the steps instance typestepsFactory- theInjectableStepsFactory
-
-
Method Detail
-
type
public Class<?> type()
-
instance
public Object instance()
-
listCandidates
public List<StepCandidate> listCandidates()
Description copied from interface:CandidateStepsReturns the step candidates that can be matched- Returns:
- The list of step candidates
-
listBeforeStories
public List<BeforeOrAfterStep> listBeforeStories()
Description copied from interface:CandidateStepsReturns the before stories steps- Returns:
- The list of the before stories steps
-
listAfterStories
public List<BeforeOrAfterStep> listAfterStories()
Description copied from interface:CandidateStepsReturns the after stories steps- Returns:
- The list of the after stories steps
-
listBeforeStory
public List<BeforeOrAfterStep> listBeforeStory(boolean givenStory)
Description copied from interface:CandidateStepsReturns the before story steps, based on the given story status- Parameters:
givenStory- the boolean flag denoting if it's a given story- Returns:
- The list of the before story steps
-
listAfterStory
public List<BeforeOrAfterStep> listAfterStory(boolean givenStory)
Description copied from interface:CandidateStepsReturns the after story steps, based on the given story status- Parameters:
givenStory- the boolean flag denoting if it's a given story- Returns:
- The list of the after story steps
-
listBeforeScenario
public Map<ScenarioType,List<BeforeOrAfterStep>> listBeforeScenario()
Description copied from interface:CandidateStepsReturns the before scenario steps- Returns:
- The list of the before scenario steps
-
listAfterScenario
public Map<ScenarioType,List<BeforeOrAfterStep>> listAfterScenario()
Description copied from interface:CandidateStepsReturns the after scenario steps- Returns:
- The list of the after scenario steps
-
-