JBehave supports the following Java method step annotations:
Each annotation holds a regex pattern as value, which is used to match the candidate steps to the textual step:
@Given("a stock of symbol $symbol and a threshold of $threshold") public void aStock(String symbol, double threshold) { // ... } @When("the stock is traded at $price") @Alias("the stock is exchanged at $price") // single alias public void theStockIsTradedAt(double price) { // ... } @Then("the alert status should be $status") @Aliases(values={"the trader should be alerted of status $status", "the alert status is at $status"}) // multiple aliases public void theAlertStatusShouldBe(String status) { // ... }
The use of aliases is optional.
JBehave supports the following Java method scenario annotations:
The BeforeScenario annotation holds no value and it allows the corresponding method to be executed before each scenario, while the AfterScenario holds an optional Outcome value, which specifies whether the method should be executed depending on the outcome of the scenario:
@BeforeScenario public void beforeEachScenario() { // ... } @AfterScenario // equivalent to @AfterScenario(uponOutcome=AfterScenario.Outcome.ANY) public void afterAnyScenario() { // ... } @AfterScenario(uponOutcome=AfterScenario.Outcome.SUCCESS) public void afterSuccessfulScenario() { // ... } @AfterScenario(uponOutcome=AfterScenario.Outcome.FAILURE) public void afterFailedScenario() { // ... }
JBehave supports the following Java method story annotations:
The BeforeStory and AfterStory annotations allow the corresponding methods to be executed before and after each story, either embedded or not:
@BeforeStory // equivalent to @BeforeStory(uponEmbedded=false) public void beforeStory() { // ... } @BeforeStory(uponEmbedded=true) public void beforeEmbeddedStory() { // ... } @AfterStory // equivalent to @AfterStory(uponEmbedded=false) public void afterStory() { // ... } @AfterStory(uponEmbedded=true) public void afterEmbeddedStory() { // ... }
JBehave supports the following Java parameter annotations:
Parameter annotations are used in parameter injection.