Skip to content

Instantly share code, notes, and snippets.

@richteri
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save richteri/b914473aa063cf4daa18 to your computer and use it in GitHub Desktop.

Select an option

Save richteri/b914473aa063cf4daa18 to your computer and use it in GitHub Desktop.
JBehave maps textual steps to Java methods via CandidateSteps. The scenario writer need only provide annotated methods that match, by regex patterns, the textual steps.
public class FormTest {
@Steps
FormSteps endUser;
@Given("the user is on the form page")
public void givenTheUserIsOnTheFormPage() {
endUser.on_the_form_page();
}
@When("the user enters the name '$name' and age '$age' and submits the form")
public void whenTheUserEntersName(String name, String age) {
endUser.enters_name(name);
endUser.enters_age(age);
endUser.posts_form();
}
@Then("they should see the error message '$errorName' for name and '$errorAge' for age")
public void thenTheyShouldSeeErrorMessages(String errorName, String errorAge) {
endUser.should_see_name_error(errorName);
endUser.should_see_age_error(errorAge);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment