Test Automation Framework using Cucumber BDD overview (part 1)
BDD using JBehave
-
Upload
ajit-skanda-kumaraswamy -
Category
Documents
-
view
950 -
download
1
Transcript of BDD using JBehave
jBehaveA Java library for Behavior Driven Development
ByAjit Skanda Kumaraswamy
Backbase BV Amsterdam29th May 2012
Tuesday, May 29, 12
In today’s presentation...
n What is Acceptance Testing?
n What is Behavior Driven Development?
n jBehave and its features
n An example jBehave test
n Salient features of jBehave
Tuesday, May 29, 12
Acceptance Testing
n What is Acceptance testing?
n Why is it important?
n Who writes Acceptance tests? When?
Tuesday, May 29, 12
Behavior Driven Development
n What is BDD?
n How is it different from TDD?
n How do we benefit from it?
n Acceptance testing and BDD
n BDD using jBehave
Tuesday, May 29, 12
Introduction to jBehaven Basic Concepts
n Story
n Steps Class
n Configuration
n Advanced topics
n jBehave with Spring and Maven
n Example in jBehave
Tuesday, May 29, 12
jBehave basics 1 - story
Example Story
Scenario: trader is not alerted below threshold Given a stock of symbol STK1 and a threshold of 10.0When the stock is traded at 5.0Then the alert status should be OFF Scenario: trader is alerted above threshold Given a stock of symbol STK1 and a threshold of 10.0When the stock is traded at 11.0Then the alert status should be ON
n A textual representation of the business feature to be developed
n A collection of scenarios for the given feature
n Can be located on the classpath or on a url
n Can be written in plain-text, ODT format and other formats like html
Tuesday, May 29, 12
jBehave basics 2 - Steps Class
Example Steps POJO class
public class TraderSteps { private Stock stock; @Given("a stock of symbol $symbol and a threshold of $threshold") public void aStock(String symbol, double threshold) { stock = new Stock(symbol, threshold); } @When("the stock is traded at $price") @Alias("the stock is sold at $price") public void theStockIsTradedAt(double price) { stock.tradeAt(price); } @Then("the alert status should be $status") public void theAlertStatusShouldBe(String status) { ensureThat(stock.getStatus().name(), equalTo(status)); } }
n Mapping textual scenario steps to Java methods
n Each annotation corresponds to one step of a given scenario
n A simple regex pattern holds the value
n After/Before - Scenario, Story and Stories
n Spring, Configuration based
Tuesday, May 29, 12
jBehave basics 3 - Configuration
n Different ways of running:
n Embedded vs storyPaths
n Local vs Remote
n Embeddable - Combining Configuration and CandidateSteps
n Configuration:
n Story parsing and loading
n StoryReporterBuilder and ViewGenerator
n Multiple stories using JUnitStories
n WebRunner Configuration (Ex. Selenium)
Tuesday, May 29, 12
jBehave advanced - Spring and Maven
n Excellent support for Spring framework
n SpringAnnotatedEmbedderRunner
n @UsingSpring
n InjectableStepsFactory for Steps beans
n jBehave Maven plugin and its configuration
n unpack, mapping, running, reporting
n A concurrent Jenkins plugin
Tuesday, May 29, 12
jBehave - Example
n An example from jBehave tutorials - Selenium tests to run stories on etsy.com
Tuesday, May 29, 12
Salient Features of jBehaven Very powerful and flexible
n Separation of text stories from code and config
n Extensive support for different frameworks and environments
n Good documentation/example and online forums
n Comprehensive reporting options
n Steep learning curve!
Tuesday, May 29, 12
Thank you
Questions?
Tuesday, May 29, 12