1 / 6

JBehave

JBehave. Create and Run a Scenario. Three files needed: Scenario text file with given-when-then format Java/file class to extend Scenario file Java steps file for the method shells. Sample scenario text file (make_pancakes_scenario). Scenario: Making pancakes in a skillet

dhollars
Download Presentation

JBehave

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JBehave

  2. Create and Run a Scenario • Three files needed: • Scenario text file with given-when-then format • Java/file class to extend Scenario file • Java steps file for the method shells

  3. Sample scenario text file (make_pancakes_scenario) Scenario: Making pancakes in a skillet Given some pancake batter And a hot frying pan When I pour the batter into the frying pan And wait for 2 minutes or until the sides are dry And flip the pancake over And wait for 1 minute Then I get a cooked pancake

  4. Sample Java file/class (MakePancakesScenario.java) package com.cse.simple.stories; import org.jbehave.scenario.Scenario; public class MakePancakesScenario extends Scenario { public MakePancakesScenario() { super (new PancakeCookingSteps() ); } }

  5. Sample Java steps file(1) (PancakeCookingSteps.java) package com.cse.simple.steps; import org.jbehave.core.annotations.Given; import org.jbehave.core.annotations.Then; import org.jbehave.core.annotations.When; public class PancakeCookingSteps { @Given(“some pancake batter”) public void howMuchBatter() { // add code for amount of batter } @Given(“hot frying pan”) public void heatFryingPan() { // add code to determine heat } @When(“I pour the batter into the frying pan”) public void startCooking() { // add code to start cooking } // continued on next slide

  6. Sample Java steps file(2) (PancakeCookingSteps.java) // continued from previous slide @When(“wait for 2 minutes or until the sides are dry”) public void cookFirstSide() { // add code to cook first side } @When(“flip the pancake”) public void flipPancake() { // add code to flip pancake } @When(“wait for 1 minute”) public void cookSecondSide() { // add code to cook second side } @Then(“I get a cooked pancake”) public void putPancakeOnPlate() { // add code to move pancake from frying pan to plate } }

More Related