SlideShare a Scribd company logo
Behaviour Driven Development
with Cucumber for Java
BDD
Domain Driven Design - DDD
● Common understanding
● Common language
● Test Driven Development - TDD
● Good technical practices
● Small steps
● Combined → Behaviour Driven Development
Test automation
 Test Driven Development, TDD – Develop it the
right way
 Behaviour Driven Development, BDD –
Develop the right thing
Three core principles
• Business and Technology should refer to the same system in
the same way
• Any system should have an identified, verifiable value
• Up-front analysis, design and planning all have a diminishing
return
Common language
Used by all involved
• Customer
• Developers
• Others?
Verifiable value
• Protect revenue
• Increase revenue
• Manage cost
• Increase brand value
• Make the product remarkable
• Provide more value to your customer
Big design up-front
• No big design up-front
• The further you plan ahead, the less accurate you will be
Three questions
• What is the most important thing the system should do?
• What is the next most important thing the system doesn't do
yet?
• If we were to switch off the system, where and what would be
the biggest impact?
Time to create a specification
Time to create a specification
When are we done?
Interpret and translate
 We need to read the spec.
 Understand it
 Translate it into code
 Parse and execute it?
 No, not all specs are created equal
Solution
Write specifications so
 Translations isn't needed
 It is possible to execute them
Format
• Given – Setup the system
• When – Change the state of the system
• Then – Verify the new state
Tools
Audience
Readers
 Customers
 Developers
Maintainers
 Product owner
 Developers
Why Cucumber
 It is one of the least technical tools
 It is a very active open source project
 It supports a variety of languages
A concrete example
Feature: Life of IT guys
In order to get good salary
As a it guy
I want to keep my boss happy
Scenario: I am a tester
Given I am a bad tester
When I go to work
Then I mess with it
And my boss fires me
But the developer likes me
Advantages
The format is
● Easy to read
● Easy to understand
● Easy to discuss
● Easy to parse
Parse and execute
● A parser is developed
● Add native code to implement the steps
 Setup – Given
 Execute – When
 Assert - Then
Write a step definition in Java
@Given("^I am a bad tester$")
public void I_am_a_bad_tester(){
System.out.println("@Given--I am a bad tester");
}
@When("^I go to work$")
public void I_go_to_work(){
System.out.println("@When---I go o work");
}
@Then("^I mess it$")
public void I_mess_with_it(){
System.out.println("@Then--I mess it");
}
@And("^my boss fires me$")
public void my_boss_fires_me(){
System.out.println("@And---my boss fires me");
}
@But("^the developer likes me$")
public void the_developer_likes_me(){
System.out.println("@But--the developer likes me");
Assert.assertTrue(false);
}
Run it and watch it fail
Write code to make the step pass
@Given("^I am a [a-zA-Z]{1,} tester$")
public void I_am_a_bad_tester(){
System.out.println("@Given--I am a bad tester");
}
@When("^I go to work$")
public void I_go_to_work(){
System.out.println("@When---I go o work");
}
@Then("^I [a-zA-Z]{1,} it$")
public void I_mess_with_it(){
System.out.println("@Then--I mess it");
}
@And("^my boss [a-zA-Z]{1,} me$")
public void my_boss_fires_me(){
System.out.println("@And---my boss fires me");
}
@But("^the developer [a-zA-Z]{1,} me$")
public void the_developer_likes_me(){
System.out.println("@But--the developer likes me");
}
Run it again and see the step
pass
Why is Cucumber better
● Compared to well known tools like JUnit?
● It isn't, it's just easier to read for non coders
● The readability has increased
● Communication is easier
Benefits
● Less unnecessary work
● Better regression tests
● Less speculative work
● Less re-work
Maintenance
 Maintained together
● Specs
● Tests
● Code
 Maven
 Continuous Integration, CI
Tips
 Always use the a common language
 Don't over specify – start easy
 Never specify implementation details
Do not focus on tools
• They will never solve the problem
• A fool with a tool is still a fool
Resources
 Cucumber - http://cukes.info/
 Selenium - http://seleniumhq.org/
 Maven - http://maven.apache.org/
 Jenkins - http://jenkins-ci.org/
 Blog -http://thomassundberg.wordpress.com/
Thank You

More Related Content

PPTX
Apex 10 commandments df14
PPTX
Test Automation Canvas
PPT
How engineering practices help business
PPTX
Session two Builders & Developers workshop Microsoft Tech Club Cairo Universi...
PPTX
Performance testing ( Approaching , Designing performance tests)
PPSX
Cucumber & gherkin language
PPTX
Apex Flex Queue: Batch Apex Liberated
PDF
iwantmyname a/b testing lessons learned
Apex 10 commandments df14
Test Automation Canvas
How engineering practices help business
Session two Builders & Developers workshop Microsoft Tech Club Cairo Universi...
Performance testing ( Approaching , Designing performance tests)
Cucumber & gherkin language
Apex Flex Queue: Batch Apex Liberated
iwantmyname a/b testing lessons learned

What's hot (15)

PDF
Defensive Apex Programming
PPTX
Sql server baselines
PDF
Never fear, the customizer is here!
PDF
Agile Testing
PPTX
Jasmine
PPTX
The Art of Gherkin Scripting - Matt Eakin
PPTX
Bdd – with cucumber and gherkin
PDF
JavaScript Unit Testing
PPTX
Zen And the Art of Test Maintenance Presentation
PPTX
Unit testing for Grown-ups
PPTX
Introduction to Bdd and cucumber
PDF
WordPress maintenance - Keeping it all running smoothly
PDF
Test-driven development with Node.js
Defensive Apex Programming
Sql server baselines
Never fear, the customizer is here!
Agile Testing
Jasmine
The Art of Gherkin Scripting - Matt Eakin
Bdd – with cucumber and gherkin
JavaScript Unit Testing
Zen And the Art of Test Maintenance Presentation
Unit testing for Grown-ups
Introduction to Bdd and cucumber
WordPress maintenance - Keeping it all running smoothly
Test-driven development with Node.js
Ad

Viewers also liked (16)

PPTX
Concurrency with java
PPTX
Datamining with nb
PDF
Andre Childs Journal_of_Raman_Spectroscopy
DOCX
Curriculum Vitae ahmed afifi 50446440 new 2016
PPT
Text classification methods
PPTX
Directory based cache coherence
PDF
Cheryl Holzknecht Resume 1
PDF
SOA2010 SOA with REST
PPT
Memory caching
PPT
Data preprocessing
PPTX
Data visualization
PPT
Віртуальна виставка нових надходжень
PPT
Hash crypto
PPTX
Object oriented programming
PPTX
Directory based cache coherence
PPTX
How analysis services caching works
Concurrency with java
Datamining with nb
Andre Childs Journal_of_Raman_Spectroscopy
Curriculum Vitae ahmed afifi 50446440 new 2016
Text classification methods
Directory based cache coherence
Cheryl Holzknecht Resume 1
SOA2010 SOA with REST
Memory caching
Data preprocessing
Data visualization
Віртуальна виставка нових надходжень
Hash crypto
Object oriented programming
Directory based cache coherence
How analysis services caching works
Ad

Similar to Behaviour driven development (20)

KEY
Beyond TDD: Enabling Your Team to Continuously Deliver Software
KEY
Driving application development through behavior driven development
PPTX
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
PPTX
BDD Primer
PPTX
BDD Selenium for Agile Teams - User Stories
PPTX
Prashant technical practices-tdd for xebia event
PPTX
Agile
PPTX
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
PPTX
Introduction to Software Engineering
PPTX
Rubyconf2016 - Solving communication problems in distributed teams with BDD
ODP
2014 11 20 Drupal 7 -> 8 test migratie
PPTX
{10.0} Test Driven Development.pptx
PPTX
A modern architecturereview–usingcodereviewtools-ver-3.5
 
PPTX
Road to Continuous Delivery - Wix.com
PPT
Developing a Culture of Quality Code (Midwest PHP 2020)
PPTX
The Challenges & Pitfalls of Database Continuous Delivery
PPTX
Software development best practices & coding guidelines
PDF
MongoDB World 2018: How an Idea Becomes a MongoDB Feature
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
PDF
Usable Software Design
Beyond TDD: Enabling Your Team to Continuously Deliver Software
Driving application development through behavior driven development
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
BDD Primer
BDD Selenium for Agile Teams - User Stories
Prashant technical practices-tdd for xebia event
Agile
Software Testing_A_mmmmmmmmmmmmmmmmmmmmm
Introduction to Software Engineering
Rubyconf2016 - Solving communication problems in distributed teams with BDD
2014 11 20 Drupal 7 -> 8 test migratie
{10.0} Test Driven Development.pptx
A modern architecturereview–usingcodereviewtools-ver-3.5
 
Road to Continuous Delivery - Wix.com
Developing a Culture of Quality Code (Midwest PHP 2020)
The Challenges & Pitfalls of Database Continuous Delivery
Software development best practices & coding guidelines
MongoDB World 2018: How an Idea Becomes a MongoDB Feature
TDD and Simple Design Workshop - Session 1 - March 2019
Usable Software Design

More from James Wong (20)

PPT
Data race
PPT
Multi threaded rtos
PPT
Recursion
PPTX
Business analytics and data mining
PPTX
Data mining and knowledge discovery
PPTX
Cache recap
PPTX
Big picture of data mining
PPTX
How analysis services caching works
PPTX
Optimizing shared caches in chip multiprocessors
PPT
Abstract data types
PPTX
Abstraction file
PPTX
Hardware managed cache
PPTX
Object model
PPT
Abstract class
PPTX
Object oriented analysis
PPTX
Data structures and algorithms
PPTX
Cobol, lisp, and python
PPTX
Inheritance
PPTX
Api crash
PPTX
Learning python
Data race
Multi threaded rtos
Recursion
Business analytics and data mining
Data mining and knowledge discovery
Cache recap
Big picture of data mining
How analysis services caching works
Optimizing shared caches in chip multiprocessors
Abstract data types
Abstraction file
Hardware managed cache
Object model
Abstract class
Object oriented analysis
Data structures and algorithms
Cobol, lisp, and python
Inheritance
Api crash
Learning python

Recently uploaded (20)

PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
project resource management chapter-09.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Getting Started with Data Integration: FME Form 101
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Zenith AI: Advanced Artificial Intelligence
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Web App vs Mobile App What Should You Build First.pdf
Programs and apps: productivity, graphics, security and other tools
A novel scalable deep ensemble learning framework for big data classification...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
1. Introduction to Computer Programming.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
OMC Textile Division Presentation 2021.pptx
A comparative study of natural language inference in Swahili using monolingua...
NewMind AI Weekly Chronicles - August'25-Week II
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
project resource management chapter-09.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
WOOl fibre morphology and structure.pdf for textiles
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Hindi spoken digit analysis for native and non-native speakers
Getting Started with Data Integration: FME Form 101
Accuracy of neural networks in brain wave diagnosis of schizophrenia

Behaviour driven development

  • 2. BDD Domain Driven Design - DDD ● Common understanding ● Common language ● Test Driven Development - TDD ● Good technical practices ● Small steps ● Combined → Behaviour Driven Development
  • 3. Test automation  Test Driven Development, TDD – Develop it the right way  Behaviour Driven Development, BDD – Develop the right thing
  • 4. Three core principles • Business and Technology should refer to the same system in the same way • Any system should have an identified, verifiable value • Up-front analysis, design and planning all have a diminishing return
  • 5. Common language Used by all involved • Customer • Developers • Others?
  • 6. Verifiable value • Protect revenue • Increase revenue • Manage cost • Increase brand value • Make the product remarkable • Provide more value to your customer
  • 7. Big design up-front • No big design up-front • The further you plan ahead, the less accurate you will be
  • 8. Three questions • What is the most important thing the system should do? • What is the next most important thing the system doesn't do yet? • If we were to switch off the system, where and what would be the biggest impact?
  • 9. Time to create a specification
  • 10. Time to create a specification When are we done?
  • 11. Interpret and translate  We need to read the spec.  Understand it  Translate it into code  Parse and execute it?  No, not all specs are created equal
  • 12. Solution Write specifications so  Translations isn't needed  It is possible to execute them
  • 13. Format • Given – Setup the system • When – Change the state of the system • Then – Verify the new state
  • 14. Tools
  • 16. Why Cucumber  It is one of the least technical tools  It is a very active open source project  It supports a variety of languages
  • 17. A concrete example Feature: Life of IT guys In order to get good salary As a it guy I want to keep my boss happy Scenario: I am a tester Given I am a bad tester When I go to work Then I mess with it And my boss fires me But the developer likes me
  • 18. Advantages The format is ● Easy to read ● Easy to understand ● Easy to discuss ● Easy to parse
  • 19. Parse and execute ● A parser is developed ● Add native code to implement the steps  Setup – Given  Execute – When  Assert - Then
  • 20. Write a step definition in Java @Given("^I am a bad tester$") public void I_am_a_bad_tester(){ System.out.println("@Given--I am a bad tester"); } @When("^I go to work$") public void I_go_to_work(){ System.out.println("@When---I go o work"); } @Then("^I mess it$") public void I_mess_with_it(){ System.out.println("@Then--I mess it"); } @And("^my boss fires me$") public void my_boss_fires_me(){ System.out.println("@And---my boss fires me"); } @But("^the developer likes me$") public void the_developer_likes_me(){ System.out.println("@But--the developer likes me"); Assert.assertTrue(false); }
  • 21. Run it and watch it fail
  • 22. Write code to make the step pass @Given("^I am a [a-zA-Z]{1,} tester$") public void I_am_a_bad_tester(){ System.out.println("@Given--I am a bad tester"); } @When("^I go to work$") public void I_go_to_work(){ System.out.println("@When---I go o work"); } @Then("^I [a-zA-Z]{1,} it$") public void I_mess_with_it(){ System.out.println("@Then--I mess it"); } @And("^my boss [a-zA-Z]{1,} me$") public void my_boss_fires_me(){ System.out.println("@And---my boss fires me"); } @But("^the developer [a-zA-Z]{1,} me$") public void the_developer_likes_me(){ System.out.println("@But--the developer likes me"); }
  • 23. Run it again and see the step pass
  • 24. Why is Cucumber better ● Compared to well known tools like JUnit? ● It isn't, it's just easier to read for non coders ● The readability has increased ● Communication is easier
  • 25. Benefits ● Less unnecessary work ● Better regression tests ● Less speculative work ● Less re-work
  • 26. Maintenance  Maintained together ● Specs ● Tests ● Code  Maven  Continuous Integration, CI
  • 27. Tips  Always use the a common language  Don't over specify – start easy  Never specify implementation details
  • 28. Do not focus on tools • They will never solve the problem • A fool with a tool is still a fool
  • 29. Resources  Cucumber - http://cukes.info/  Selenium - http://seleniumhq.org/  Maven - http://maven.apache.org/  Jenkins - http://jenkins-ci.org/  Blog -http://thomassundberg.wordpress.com/