JBehave supports the following 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 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 method story annotations:
The @BeforeStory and @AfterStory annotations allow the corresponding methods to be executed before and after each story, either a GivenStory or not:
@BeforeStory // equivalent to @BeforeStory(uponGivenStory=false)
public void beforeStory() {
// ...
}
@BeforeStory(uponGivenStory=true)
public void beforeGivenStory() {
// ...
}
@AfterStory // equivalent to @AfterStory(uponGivenStory=false)
public void afterStory() {
// ...
}
@AfterStory(uponGivenStory=true)
public void afterGivenStory() {
// ...
}
JBehave supports the following method stories annotations:
The @BeforeStories and @AfterStories annotations allow the corresponding methods to be executed before and after a collection of stories:
@BeforeStories
public void beforeStories() {
// ...
}
@AfterStories
public void afterStories() {
// ...
}
JBehave supports the following parameter annotations:
Parameter annotations are used in parameter injection.
JBehave supports the following configuration annotations: