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 (20)

PPT
Prolog resume
PPT
Google mock for dummies
PPTX
Data visualization
PPTX
Network
PPT
Exception
PPT
Xml and webdata
PPTX
Test driven development
PPT
Reflection
PPTX
Nlp naive bayes
PPTX
Exception handling
PPT
Html5
PPTX
Decision analysis
PDF
Text categorization as a graph
PPT
Text classificationmethods
PPT
Database introduction
PPT
Sql database object
PPT
Polymorphism
PPT
Basic dns-mod
PPTX
Cryptography
PPTX
Overview prolog
Prolog resume
Google mock for dummies
Data visualization
Network
Exception
Xml and webdata
Test driven development
Reflection
Nlp naive bayes
Exception handling
Html5
Decision analysis
Text categorization as a graph
Text classificationmethods
Database introduction
Sql database object
Polymorphism
Basic dns-mod
Cryptography
Overview prolog
Ad

Similar to Behaviour driven development (20)

PPTX
BDD using Cucumber JVM
PPTX
Cucumber jvm best practices v3
PPT
Behavior Driven Development by Example
PDF
cucumber harpal.pdf
PPTX
BDD Selenium for Agile Teams - User Stories
PDF
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
PPTX
Behavior Driven Development
PPTX
Automation test framework with cucumber – BDD
PPTX
BDD testing with cucumber
PDF
BDD with the Cucumber
PPTX
Bdd with Cucumber and Mocha
PPTX
Xamariners - BDD + Mobile
ODP
Test Automation Framework using Cucumber BDD overview (part 1)
PPTX
BDD from QA side
PPTX
BDD WITH CUCUMBER AND JAVA
PDF
Introduction to BDD with Cucumber for Java
PPTX
presentation.pptx
PDF
Cucumber tutorial
PDF
BDD & Cucumber
PDF
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
BDD using Cucumber JVM
Cucumber jvm best practices v3
Behavior Driven Development by Example
cucumber harpal.pdf
BDD Selenium for Agile Teams - User Stories
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
Behavior Driven Development
Automation test framework with cucumber – BDD
BDD testing with cucumber
BDD with the Cucumber
Bdd with Cucumber and Mocha
Xamariners - BDD + Mobile
Test Automation Framework using Cucumber BDD overview (part 1)
BDD from QA side
BDD WITH CUCUMBER AND JAVA
Introduction to BDD with Cucumber for Java
presentation.pptx
Cucumber tutorial
BDD & Cucumber
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman

More from Fraboni Ec (20)

PPT
Hardware multithreading
PPT
PDF
What is simultaneous multithreading
PPTX
Directory based cache coherence
PPTX
Business analytics and data mining
PPTX
Big picture of data mining
PPTX
Data mining and knowledge discovery
PPTX
Cache recap
PPTX
How analysis services caching works
PPTX
Hardware managed cache
PPTX
Data structures and algorithms
PPTX
Cobol, lisp, and python
PPT
Abstract data types
PPTX
Optimizing shared caches in chip multiprocessors
PPTX
Abstraction file
PPTX
Object model
PPTX
Object oriented analysis
PPT
Abstract class
PPTX
Concurrency with java
PPTX
Inheritance
Hardware multithreading
What is simultaneous multithreading
Directory based cache coherence
Business analytics and data mining
Big picture of data mining
Data mining and knowledge discovery
Cache recap
How analysis services caching works
Hardware managed cache
Data structures and algorithms
Cobol, lisp, and python
Abstract data types
Optimizing shared caches in chip multiprocessors
Abstraction file
Object model
Object oriented analysis
Abstract class
Concurrency with java
Inheritance

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PDF
Approach and Philosophy of On baking technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KodekX | Application Modernization Development
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
MIND Revenue Release Quarter 2 2025 Press Release
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
Approach and Philosophy of On baking technology
Big Data Technologies - Introduction.pptx
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

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/