Class Steps
- All Implemented Interfaces:
CandidateSteps
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
Stepsclass, in which case the instance is the extendedStepsclass itself ("is-a" relationship)
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 Summary
ConstructorsConstructorDescriptionSteps()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 TypeMethodDescriptioninstance()Returns the after scenario stepsReturns the after stories stepslistAfterStory(boolean givenStory) Returns the after story steps, based on the given story status<T extends Annotation>
Map<ScenarioType,List<BeforeOrAfterStep>> listBeforeOrAfterScenarioSteps(Class<T> annotationClass, BiPredicate<T, ScenarioType> predicate, ToIntFunction<T> order, Function<T, AfterScenario.Outcome> outcome) Returns the before scenario stepsReturns the before stories stepslistBeforeStory(boolean givenStory) Returns the before story steps, based on the given story statusReturns the step candidates that can be matchedtoString()Class<?>type()Methods inherited from class org.jbehave.core.steps.AbstractCandidateSteps
addCandidatesFromVariants, configuration, createStepCreator
-
Constructor Details
-
Steps
public Steps()Creates Steps with default configuration for a class extending this instance and containing the candidate step methods -
Steps
Creates Steps with given custom configuration for a class extending this instance and containing the candidate step methods- Parameters:
configuration- the Configuration
-
Steps
Creates Steps with given custom configuration and a steps instance containing the candidate step methods- Parameters:
configuration- the Configurationinstance- the steps instance
-
Steps
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 Details
-
type
-
instance
-
listCandidates
Description copied from interface:CandidateStepsReturns the step candidates that can be matched- Returns:
- The list of step candidates
-
listBeforeStories
Description copied from interface:CandidateStepsReturns the before stories steps- Returns:
- The list of the before stories steps
-
listAfterStories
Description copied from interface:CandidateStepsReturns the after stories steps- Returns:
- The list of the after stories steps
-
listBeforeStory
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
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
Description copied from interface:CandidateStepsReturns the before scenario steps- Returns:
- The list of the before scenario steps
-
listAfterScenario
Description copied from interface:CandidateStepsReturns the after scenario steps- Returns:
- The list of the after scenario steps
-
listBeforeOrAfterScenarioSteps
public <T extends Annotation> Map<ScenarioType,List<BeforeOrAfterStep>> listBeforeOrAfterScenarioSteps(Class<T> annotationClass, BiPredicate<T, ScenarioType> predicate, ToIntFunction<T> order, Function<T, AfterScenario.Outcome> outcome) -
toString
-