SlideShare a Scribd company logo
DHAWAL JOSHI
AJIT KUMAR NARAYANAN
MAKING BDD FUN WITH CUCUMBER, JASMINE AND …
BDD ?
BDD
 TDD
• Write Tests first
• Watch it fail
• Write enough code to make the test pass
• Continue
 But, soon
• Where do I start ?, What should I test
• What should I call the tests
• Why is that test failing and what user stories does it impact ?
 BDD
 = TDD + Stakeholder Value + Collaboration + Behaviour
 Usually written on top of DSLs that resemble natural language ( Only to address Collaboration)
Who needs to know BDD?
Product Owner / Stakeholder Developer Tester
Principles
 Think Behaviour & everyone speaks the same language
 And about stakeholder value
 Enough is enough
Traditional Way
Product Owner /
Stakeholder
Developer
Tester
User Stories
Clarifications
Specifications, Design
Test Case Document
There are many
Bugs !
But, see it is in
The test case
document
But, it was never
Specified …
That’s correct. It
Is the right spec !
Well, you never
Told me
I told the tester.
Aren’t you guys in one
Team ???
BDD Way
Product Owner /
Stakeholder
DeveloperTester
User Stories
Clarifications
SpecificationsTest Case Document
We better start
collaborating better
and talk same language
We better start
collaborating better
and talk same language
We better start
collaborating better
and talk same language
Ubiquitous Language
1: Think Behaviour & everyone speaks the same language
Value
2: Stakeholder value
Product Owner /
Stakeholder
In Order to [Business Value]
As a [Role]
I want to [Feature]
1. Protect Revenue
2. Increase Revenue
3. Manage Cost
How much is Enough ?
3: Enough is Enough
1. No Over engineering
2. No Overdoing { planning, Analysis and Design }
3. There is no such thing as a perfect software
Ubiquitous Language
A Language structured around the domain model that everyone in the team
understands.
A Language capable to express a feature, its business value and behaviour (
Behaviour = Context Action Outcome )
ENTER GHERKIN
Gherkin ?
1. Business Readable DSL that expresses the ‘what’ of the software without specifying the
‘how’ i.e it describes Behaviour
2. Serves 2 Purposes : Documentation + Automated testing
3. Line oriented language like python or YAML; Uses indentation to define structure
Gherkin ?
Feature: Search courses
In order to ensure better utilization of courses
Potential students should be able to search for courses
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 2 courses A001, B205 that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| Course code |
| A001 |
| B205 |
Context
Action
Outcome
Behavior
ENTER CUCUMBER
Cucumber ?
1. Is a Tool that executes plain-text functional descriptions as automated tests
2. Understands the ‘Gherkin’ Language
3. Itself is written in Ruby, but can be used for several languages
4. Has several language specific variations : E.g : Cucumber.js , Cucumber JVM etc …
Cucumber ?
Feature: Search courses
In order to ensure better utilization of courses
Potential students should be able to search for courses
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 2 courses A001, B205 that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| Course code |
| A001 |
| B205 |
Feature
Step Definitions ( Regex)
Scenario ( 5- 25)
Cucumber ?
Product Owner /
Stakeholder
DeveloperTester
Features
Step Definitions
Cucumber : Organizing your features
Project Root
features
support
step_defenitions
Thegreatest.feature
Theultimate.feature
Thegreatest_steps.rb
Theultimate_steps.rb
env.rb
Cucumber : Organizing your features
step definition
Given there are 200 elements in the stack Given /^there are (d+) elements in the queue’ do
#DO SOMETHING HERE
@stack= Stack.new
200.times do |i|
@stack.push(‘item’ + i.to_s)
end
end
Cucumber : Organizing your features
step definition
Given there are 200 elements in the stack
When I add another element
When /^I add another element’ do
@stack.push ‘itemanother’
end
Cucumber : Organizing your features
step definition
Given there are 200 elements in the stack
When I add another element
Then there should be 201 elements
Then /^There should be (d+) elements’ do
@stack.count.should == 201
end
MAP THIS TO AGILE TEST MATRIX
Cucumber & Agile test matrix
Cucumber / Variants
BUT, NOT ALL Q2 TESTS ARE API BASED
TESTS
ENTER CAPYBARA, SELENIUM, WEBRAT,
ZOMBIE.JS AND 100 OTHER WEB APP
TEST FRAMEWORKS
CAPYBARA
.is a library that can be used with cucumber to write tests that also need javascript support.
SELENIUM
… automates web browsers across many platform
WEBRAT
… allows to quickly write robust and thorough acceptance tests for a web application. By
leveraging the DOM, it can run tests similarly to an in-browser testing solution without the
associated performance hit (and browser dependency)
JASMINE
Jasmine
1. Yet another BDD framework for testing your java script code
2. Evolved from Rspec
3. Suited for Q1 Tests
4. Can run in browser or server-side environments like node.js
describe (“<UNIT NAME >”, function() {
describe(“<BEHAVIOUR>”, function () {
it(“<SHOULD DO WHAT >, function (){
});
});
});
Jasmine
describe (“Customer Model”, function() {
var cust = new Customer();
describe(“When saved without an ID”, function () {
cust.id = null;
it(“should throw an ID cannot be null exception”, function (){
expect(custid.save()).toThrow(“IDCannotbeNull”);
});
});
});
Your behavior reads : “Customer Model when saved without an ID should throw an ID cannot
be null exception”
Spec File
Cucumber : Organizing your Specs
Project Root
spec
SomeUnitspec.js
models
Customermodelspec.js
SpecRunner.html
Jasmine & Agile test matrix
Cucumber / Variants
TYPICAL FLOW
Typical Flow
Write the Features
(DEV, PO, QE)
Refine Features
(DEV, PO, QE)
Add Step Definitions
(DEV, QE)
Write the code
/ UI that you wished
you had
(QE/Dev)
RunTest
Do you want to add/modify a unit ?
Describe Behavior
(Dev , Verified by Arch)RunTestWrite enough to
Make test pass
Q2
Q1 (Dev Territory)
Pass
Backlog Grooming
Fail
SIMPLE EXAMPLE - LIVE

More Related Content

PPTX
Cucumber_Training_ForQA
PPTX
DSL in test automation
PPT
Internal DSLs For Automated Functional Testing
PPTX
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
PPTX
Testing with cucumber testing framework
PPTX
DSL, Page Object and Selenium – a way to reliable functional tests
PDF
eXtreme Programming
PPTX
Java Script An Introduction By HWA
Cucumber_Training_ForQA
DSL in test automation
Internal DSLs For Automated Functional Testing
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
Testing with cucumber testing framework
DSL, Page Object and Selenium – a way to reliable functional tests
eXtreme Programming
Java Script An Introduction By HWA

What's hot (20)

PPTX
1. java script language fundamentals
ODP
CLEAN CODE
PPTX
Clean code, Feb 2012
PPT
Clean code
PPTX
Introduction to Java Script
PPT
Java script
PPTX
Introduction to Core Java Programming
PPT
Java script
PDF
Detangling Your JavaScript
PPTX
Writing High Quality Code in C#
PPTX
BDD Primer
KEY
Javascript Tests with Jasmine for Front-end Devs
PPTX
Clean code coding like a professional
PPTX
Coding conventions
PPTX
04 managing the database
PPTX
Coding conventions
PPTX
Clean code
PPTX
02 java programming basic
PPTX
iOS Development at Scale @Chegg
1. java script language fundamentals
CLEAN CODE
Clean code, Feb 2012
Clean code
Introduction to Java Script
Java script
Introduction to Core Java Programming
Java script
Detangling Your JavaScript
Writing High Quality Code in C#
BDD Primer
Javascript Tests with Jasmine for Front-end Devs
Clean code coding like a professional
Coding conventions
04 managing the database
Coding conventions
Clean code
02 java programming basic
iOS Development at Scale @Chegg
Ad

Similar to Behavior Driven Development (20)

PPTX
CucumberSeleniumWD
PPT
Behavior Driven Development by Example
PPTX
Behaviour Driven Development V 0.1
PPTX
Introduction to Behaviour Driven Development (BDD) and Cucumber with Java
PDF
TDD and BDD in Sky Deutschland
PPTX
Top 20 cucumber interview questions for sdet
PDF
cucumber harpal.pdf
PDF
Mastering BDD with Cucumber & Java for Test Automation
PDF
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
PPTX
Test team dynamics, Антон Мужайло
PPTX
PHPConf.asia 2016 - BDD with Behat for Beginners
PPTX
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
PPTX
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
PDF
When develpment met test(shift left testing)
PPTX
Understanding Why Testing is Importaint
PPTX
Automated Acceptance Tests & Tool choice
PPTX
Zend con 2016 bdd with behat for beginners
PPTX
Test driven development v1.0
PPTX
BDD Selenium for Agile Teams - User Stories
CucumberSeleniumWD
Behavior Driven Development by Example
Behaviour Driven Development V 0.1
Introduction to Behaviour Driven Development (BDD) and Cucumber with Java
TDD and BDD in Sky Deutschland
Top 20 cucumber interview questions for sdet
cucumber harpal.pdf
Mastering BDD with Cucumber & Java for Test Automation
Behavior Driven Development—A Guide to Agile Practices by Josh Eastman
Test team dynamics, Антон Мужайло
PHPConf.asia 2016 - BDD with Behat for Beginners
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
DevLabs Alliance top 20 Cucumber Interview Questions for SDET
When develpment met test(shift left testing)
Understanding Why Testing is Importaint
Automated Acceptance Tests & Tool choice
Zend con 2016 bdd with behat for beginners
Test driven development v1.0
BDD Selenium for Agile Teams - User Stories
Ad

Recently uploaded (20)

PDF
Advanced IT Governance
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
Teaching material agriculture food technology
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Network Security Unit 5.pdf for BCA BBA.
Advanced IT Governance
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Dropbox Q2 2025 Financial Results & Investor Presentation
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Teaching material agriculture food technology
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25 Week I
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Network Security Unit 5.pdf for BCA BBA.

Behavior Driven Development

  • 1. DHAWAL JOSHI AJIT KUMAR NARAYANAN MAKING BDD FUN WITH CUCUMBER, JASMINE AND …
  • 3. BDD  TDD • Write Tests first • Watch it fail • Write enough code to make the test pass • Continue  But, soon • Where do I start ?, What should I test • What should I call the tests • Why is that test failing and what user stories does it impact ?  BDD  = TDD + Stakeholder Value + Collaboration + Behaviour  Usually written on top of DSLs that resemble natural language ( Only to address Collaboration)
  • 4. Who needs to know BDD? Product Owner / Stakeholder Developer Tester
  • 5. Principles  Think Behaviour & everyone speaks the same language  And about stakeholder value  Enough is enough
  • 6. Traditional Way Product Owner / Stakeholder Developer Tester User Stories Clarifications Specifications, Design Test Case Document There are many Bugs ! But, see it is in The test case document But, it was never Specified … That’s correct. It Is the right spec ! Well, you never Told me I told the tester. Aren’t you guys in one Team ???
  • 7. BDD Way Product Owner / Stakeholder DeveloperTester User Stories Clarifications SpecificationsTest Case Document We better start collaborating better and talk same language We better start collaborating better and talk same language We better start collaborating better and talk same language Ubiquitous Language 1: Think Behaviour & everyone speaks the same language
  • 8. Value 2: Stakeholder value Product Owner / Stakeholder In Order to [Business Value] As a [Role] I want to [Feature] 1. Protect Revenue 2. Increase Revenue 3. Manage Cost
  • 9. How much is Enough ? 3: Enough is Enough 1. No Over engineering 2. No Overdoing { planning, Analysis and Design } 3. There is no such thing as a perfect software
  • 10. Ubiquitous Language A Language structured around the domain model that everyone in the team understands. A Language capable to express a feature, its business value and behaviour ( Behaviour = Context Action Outcome )
  • 12. Gherkin ? 1. Business Readable DSL that expresses the ‘what’ of the software without specifying the ‘how’ i.e it describes Behaviour 2. Serves 2 Purposes : Documentation + Automated testing 3. Line oriented language like python or YAML; Uses indentation to define structure
  • 13. Gherkin ? Feature: Search courses In order to ensure better utilization of courses Potential students should be able to search for courses Scenario: Search by topic Given there are 240 courses which do not have the topic "biology" And there are 2 courses A001, B205 that each have "biology" as one of the topics When I search for "biology" Then I should see the following courses: | Course code | | A001 | | B205 | Context Action Outcome Behavior
  • 15. Cucumber ? 1. Is a Tool that executes plain-text functional descriptions as automated tests 2. Understands the ‘Gherkin’ Language 3. Itself is written in Ruby, but can be used for several languages 4. Has several language specific variations : E.g : Cucumber.js , Cucumber JVM etc …
  • 16. Cucumber ? Feature: Search courses In order to ensure better utilization of courses Potential students should be able to search for courses Scenario: Search by topic Given there are 240 courses which do not have the topic "biology" And there are 2 courses A001, B205 that each have "biology" as one of the topics When I search for "biology" Then I should see the following courses: | Course code | | A001 | | B205 | Feature Step Definitions ( Regex) Scenario ( 5- 25)
  • 17. Cucumber ? Product Owner / Stakeholder DeveloperTester Features Step Definitions
  • 18. Cucumber : Organizing your features Project Root features support step_defenitions Thegreatest.feature Theultimate.feature Thegreatest_steps.rb Theultimate_steps.rb env.rb
  • 19. Cucumber : Organizing your features step definition Given there are 200 elements in the stack Given /^there are (d+) elements in the queue’ do #DO SOMETHING HERE @stack= Stack.new 200.times do |i| @stack.push(‘item’ + i.to_s) end end
  • 20. Cucumber : Organizing your features step definition Given there are 200 elements in the stack When I add another element When /^I add another element’ do @stack.push ‘itemanother’ end
  • 21. Cucumber : Organizing your features step definition Given there are 200 elements in the stack When I add another element Then there should be 201 elements Then /^There should be (d+) elements’ do @stack.count.should == 201 end
  • 22. MAP THIS TO AGILE TEST MATRIX
  • 23. Cucumber & Agile test matrix Cucumber / Variants
  • 24. BUT, NOT ALL Q2 TESTS ARE API BASED TESTS
  • 25. ENTER CAPYBARA, SELENIUM, WEBRAT, ZOMBIE.JS AND 100 OTHER WEB APP TEST FRAMEWORKS
  • 26. CAPYBARA .is a library that can be used with cucumber to write tests that also need javascript support. SELENIUM … automates web browsers across many platform WEBRAT … allows to quickly write robust and thorough acceptance tests for a web application. By leveraging the DOM, it can run tests similarly to an in-browser testing solution without the associated performance hit (and browser dependency)
  • 28. Jasmine 1. Yet another BDD framework for testing your java script code 2. Evolved from Rspec 3. Suited for Q1 Tests 4. Can run in browser or server-side environments like node.js describe (“<UNIT NAME >”, function() { describe(“<BEHAVIOUR>”, function () { it(“<SHOULD DO WHAT >, function (){ }); }); });
  • 29. Jasmine describe (“Customer Model”, function() { var cust = new Customer(); describe(“When saved without an ID”, function () { cust.id = null; it(“should throw an ID cannot be null exception”, function (){ expect(custid.save()).toThrow(“IDCannotbeNull”); }); }); }); Your behavior reads : “Customer Model when saved without an ID should throw an ID cannot be null exception” Spec File
  • 30. Cucumber : Organizing your Specs Project Root spec SomeUnitspec.js models Customermodelspec.js SpecRunner.html
  • 31. Jasmine & Agile test matrix Cucumber / Variants
  • 33. Typical Flow Write the Features (DEV, PO, QE) Refine Features (DEV, PO, QE) Add Step Definitions (DEV, QE) Write the code / UI that you wished you had (QE/Dev) RunTest Do you want to add/modify a unit ? Describe Behavior (Dev , Verified by Arch)RunTestWrite enough to Make test pass Q2 Q1 (Dev Territory) Pass Backlog Grooming Fail