SlideShare a Scribd company logo
1 of 12
Download to read offline
jBehave
                      A Java library for Behavior Driven Development

                                          By
                              Ajit Skanda Kumaraswamy
                                      (ajit@backbase.com)


                                 Backbase BV Amsterdam
                                        29th 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 jBehave
            n        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

                n    A textual representation of the     Example Story
                      business feature to be
                      developed                           Scenario:  trader is not alerted below
                                                          threshold
                                                           
                n    A collection of scenarios for the   Given a stock of symbol STK1 and a
                      given feature                       threshold of 10.0
                                                          When the stock is traded at 5.0
                                                          Then the alert status should be OFF
                n    Can be located on the classpath      
                      or on a url                         Scenario:  trader is alerted above
                                                          threshold
                                                           
                n    Can be written in plain-text,       Given a stock of symbol STK1 and a
                                                          threshold of 10.0
                      ODT format and other formats        When the stock is traded at 11.0
                      like html                           Then the alert status should be ON




Tuesday, May 29, 12
jBehave basics 2 - Steps Class

                n    Mapping textual scenario steps   Example Steps POJO class
                      to Java methods
                                                       public class TraderSteps {
                                                           private Stock stock;

                n    Each annotation corresponds to    
                                                           @Given("a stock of symbol $symbol and a threshold of

                      one step of a given scenario     $threshold")
                                                           public void aStock(String symbol, double threshold) {
                                                               stock = new Stock(symbol, threshold);
                                                           }
                                                        
                n    A simple regex pattern holds         @When("the stock is traded at $price")
                                                           @Alias("the stock is sold at $price")
                      the value                            public void theStockIsTradedAt(double price) {
                                                               stock.tradeAt(price);
                                                           }
                                                        

                n    After/Before - Scenario, Story       @Then("the alert status should be $status")
                                                           public void theAlertStatusShouldBe(String status) {

                      and Stories                              ensureThat(stock.getStatus().name(), equalTo(status));
                                                           }
                                                        
                                                       }

                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 jBehave
            n        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

More Related Content

What's hot

Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaIosif Itkin
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberAsheesh Mehdiratta
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testingsjmarsh
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Robin O'Brien
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasGeison Goes
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraBindesh Vijayan
 
OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式CodeData
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVMAlan Parkinson
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for seleniumapoorvams
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day OneTroy Miles
 
Visage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIsVisage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIsStephen Chin
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsMert Çalışkan
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)Alexander Casall
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...KMS Technology
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)Tze Yang Ng
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 

What's hot (20)

Exactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in KostromaExactpro Systems for KSTU Students in Kostroma
Exactpro Systems for KSTU Students in Kostroma
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
So What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With TestingSo What Do Cucumbers Have To Do With Testing
So What Do Cucumbers Have To Do With Testing
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)
 
Cucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criteriasCucumber - use it to describe user stories and acceptance criterias
Cucumber - use it to describe user stories and acceptance criterias
 
Ruby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybaraRuby onrails cucumber-rspec-capybara
Ruby onrails cucumber-rspec-capybara
 
OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式OCM Java 開發人員認證與設計模式
OCM Java 開發人員認證與設計模式
 
Test automation with Cucumber-JVM
Test automation with Cucumber-JVMTest automation with Cucumber-JVM
Test automation with Cucumber-JVM
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 
Cucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and GroovyCucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and Groovy
 
Workflow Yapceu2010
Workflow Yapceu2010Workflow Yapceu2010
Workflow Yapceu2010
 
Visage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIsVisage Android - Cleaner APIs, Cleaner UIs
Visage Android - Cleaner APIs, Cleaner UIs
 
Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent Projects
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)JavaFX in Action (devoxx'16)
JavaFX in Action (devoxx'16)
 
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
Behavior-Driven Development and Automation Testing Using Cucumber Framework W...
 
The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)The LAZY Developer's Guide to BDD (with Cucumber)
The LAZY Developer's Guide to BDD (with Cucumber)
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 

Similar to BDD using JBehave

Building Large-scale Real-world Recommender Systems - Recsys2012 tutorial
Building Large-scale Real-world Recommender Systems - Recsys2012 tutorialBuilding Large-scale Real-world Recommender Systems - Recsys2012 tutorial
Building Large-scale Real-world Recommender Systems - Recsys2012 tutorialXavier Amatriain
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritancebergel
 
Core Java Training
Core Java TrainingCore Java Training
Core Java TrainingDeccansoft
 
What have the annotations done to us?
What have the annotations done to us?What have the annotations done to us?
What have the annotations done to us?Adam Warski
 
object oriented programming(PYTHON)
object oriented programming(PYTHON)object oriented programming(PYTHON)
object oriented programming(PYTHON)Jyoti shukla
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 

Similar to BDD using JBehave (9)

BeJUG JavaFx In Practice
BeJUG JavaFx In PracticeBeJUG JavaFx In Practice
BeJUG JavaFx In Practice
 
Building Large-scale Real-world Recommender Systems - Recsys2012 tutorial
Building Large-scale Real-world Recommender Systems - Recsys2012 tutorialBuilding Large-scale Real-world Recommender Systems - Recsys2012 tutorial
Building Large-scale Real-world Recommender Systems - Recsys2012 tutorial
 
DEVCON1 - BooJs
DEVCON1 - BooJsDEVCON1 - BooJs
DEVCON1 - BooJs
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritance
 
Core Java Training
Core Java TrainingCore Java Training
Core Java Training
 
What have the annotations done to us?
What have the annotations done to us?What have the annotations done to us?
What have the annotations done to us?
 
object oriented programming(PYTHON)
object oriented programming(PYTHON)object oriented programming(PYTHON)
object oriented programming(PYTHON)
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 

BDD using JBehave

  • 1. jBehave A Java library for Behavior Driven Development By Ajit Skanda Kumaraswamy (ajit@backbase.com) Backbase BV Amsterdam 29th May 2012 Tuesday, May 29, 12
  • 2. 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
  • 3. Acceptance Testing n What is Acceptance testing? n Why is it important? n Who writes Acceptance tests? When? Tuesday, May 29, 12
  • 4. 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
  • 5. Introduction to jBehave n 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
  • 6. jBehave basics 1 - story n A textual representation of the Example Story business feature to be developed Scenario:  trader is not alerted below threshold   n A collection of scenarios for the Given a stock of symbol STK1 and a given feature threshold of 10.0 When the stock is traded at 5.0 Then the alert status should be OFF n Can be located on the classpath   or on a url Scenario:  trader is alerted above threshold   n Can be written in plain-text, Given a stock of symbol STK1 and a threshold of 10.0 ODT format and other formats When the stock is traded at 11.0 like html Then the alert status should be ON Tuesday, May 29, 12
  • 7. jBehave basics 2 - Steps Class n Mapping textual scenario steps Example Steps POJO class to Java methods public class TraderSteps {     private Stock stock; n Each annotation corresponds to       @Given("a stock of symbol $symbol and a threshold of one step of a given scenario $threshold")     public void aStock(String symbol, double threshold) {         stock = new Stock(symbol, threshold);     }   n A simple regex pattern holds     @When("the stock is traded at $price") @Alias("the stock is sold at $price") the value     public void theStockIsTradedAt(double price) {         stock.tradeAt(price);     }   n After/Before - Scenario, Story     @Then("the alert status should be $status")     public void theAlertStatusShouldBe(String status) { and Stories         ensureThat(stock.getStatus().name(), equalTo(status));     }   } n Spring, Configuration based Tuesday, May 29, 12
  • 8. 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
  • 9. 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
  • 10. jBehave - Example n An example from jBehave tutorials - Selenium tests to run stories on etsy.com Tuesday, May 29, 12
  • 11. Salient Features of jBehave n 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
  • 12. Thank you Questions? Tuesday, May 29, 12