SlideShare a Scribd company logo
Behavior Driven Development
with Cucumber JVM
By Gopal Shah
Agenda
● TDD session recap
● BDD solution analysis
● Cucumber features
● Alternative BDD frameworks
● Q & A
BDD impact
● Behavior is more useful than “test”
● Ubiquitous language
● Increased collaboration
● Living documentation
Cucumber internals
● Gherkin
● Ignores keywords
● Step results → Passed, Failed, Pending,
Undefined
● World object
Tips & Tricks
● Use capture groups
● Distinguish singular/plural with '?'
● Use non-capturing groups (?:visit|go to)
When I visit the homepage
When I go to the homepage
● Use anchors (“^ … $”)
● Use tags and folders to organize
Use Doc Strings
Scenario: Ban Unscrupulous Users
When I behave unscrupulously
Then I should receive an email containing:
"""
Dear Sir,
Your account privileges have been revoked due to your unscrupulous behavior.
Sincerely,
The Management
"""
And my account should be locked
Doc Strings Step Defn
@When("^I behave unscrupulously$")
@Then("^I should receive an email containing:$")
public void I_should_receive_an_email_containing(String
arg1) throws Throwable {
throw new PendingException();
}
@Then("^my account should be locked$")
Data Tables
Scenario:
Given a board like this:
| | 1 | 2 | 3 |
| 1 | | | |
| 2 | | | |
| 3 | | | |
When player x plays in row 2, column 1
Then the board should look like this:
| | 1 | 2 | 3 |
| 1 | | | |
| 2 | x | | |
| 3 | | | |
Data tables Step Defn
@Given("^a board like this:$")
public void a_board_like_this(String[][] twoDStringArray)
{}
@When("^player x plays in row (d+), column (d+)$")
public void player_x_plays_in_row_column(int row, int
column) {}
@Then("^the board should look like this:$")
public void the_board_should_look_like_this(String[][]
twoDStringArray) {}
Scenario Hooks
import cucumber.annotation.After;
import cucumber.annotation.Before;
@Before public void beforeScenario() {
tomcat.start();
tomcat.deploy("myapp");
}
@After public void afterScenario() {
tomcat.stop();
}
Tagged Hooks
@Before(value = {"@txn"}, order = 100)
public void startTransaction() {
}
@After(value = {"@txn"}, order = 100)
public void rollBackTransaction() {
}
SpringTransactionHooks
Global Hooks
@Before("@web")
public void beforeScenario() {
if (!tomcat.isRunning()) {
tomcat.start();
tomcat.deploy("myapp");
browser = new FirefoxDriver();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
browser.close();
tomcat.stop();
}
}); } }
Features vs Stories
Recommended NOT to do the following:
features/
story_38971_generate_new_report.feature
story_38986_run_report.feature
story_39004_log_in.feature
How NOT to have bored
stakeholders
Scenario: Check inbox
Given a User "Dave" with password "password"
And a User "Sue" with password "secret"
And an email to "Dave" from "Sue"
When I sign in as "Dave" with password
"password"
Then I should see 1 email from "Sue" in my
inbox
Avoid incidental details
Scenario: Check inbox
Given a User "Dave"
And a User "Sue"
And an email to "Dave" from "Sue"
When I sign in as "Dave"
Then I should see 1 email from "Sue" in my inbox
Can be further improved ...
Scenario: Check inbox
Given I have received an email from "Sue"
When I sign in
Then I should see 1 email from "Sue" in my inbox
Imperative steps
Feature: Animal Submission
As a Zoologist
I want to add a new animal to the site
So that I can share my animal knowledge with the community
Scenario: successful submission
Given I'm on the animal creation page
When I fill in Name with 'Alligator'
And select Phylum as 'Chordata'
And fill in Animal Class with 'Sauropsida'
And fill in Order with 'Crocodilia'
And fill in Family with 'Alligatoridae'
And fill in Genus with 'Alligator'
And check Lay Eggs
And click the Create button
Then I should see the notice 'Thank you for your animal submission!'
And the page should include the animal's name, phylum, animal
class, order, family, and genus
Declarative steps
Feature: Animal Submission
As a Zoologist
I want to add a new animal to the site
So that I can share my animal knowledge with the
community
Scenario: successful submission
Given I'm on the animal creation page
When I add a new animal
Then I should see the page for my newly created animal
And the notice 'Thank you for your animal submission!'
StepDefn for Declarative steps
@When("^I add a new animal$")
public void I_add_a_new_animal() throws Throwable {
fillsIn("Name",with("Alligator"));
selects("Chordata"),from("Phylum"));
fillsIn("Animal Class",with("Sauropsida"));
fillsIn("Order",with("Crocodilia"));
fillsIn("Family",with("Alligatoridae"));
fillsIn("Genus",with("Alligator"));
checks("Lay Eggs");
clicks_button("Create");}
Don't make it too declarative …
Scenario: The whole system
Given the system exists
When I use it
Then it should work, perfectly
Alternative frameworks
● Jbehavior
+ve: namedParameters, compositeSteps
-ve: DocString, formatting, gherkin standards
● Concordian
Composite steps in JBehavior
@Given("%customer has previously bought a %product") //
used in normal parameter matching
@Alias("<customer> has previously bought a <product>") //
used in parameterised scenarios
@Composite(steps = { "Given <customer> is logged in",
"Given <customer> has a cart",
"When a <product> is added to the cart" })
public void aCompositeStep(@Named("customer") String
customer, @Named("product") String product) { }

More Related Content

What's hot

Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
Aaron Huang
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
Gil Fink
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
Rebecca Murphey
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
Bedis ElAchèche
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesSimon Willison
 
Crowdsourcing with Django
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with Django
Simon Willison
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
Howard Lewis Ship
 
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Introduction to DBIx::Lite - Kyoto.pm tech talk #2Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Introduction to DBIx::Lite - Kyoto.pm tech talk #2Hiroshi Shibamura
 
DataMapper @ RubyEnRails2009
DataMapper @ RubyEnRails2009DataMapper @ RubyEnRails2009
DataMapper @ RubyEnRails2009
Dirkjan Bussink
 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
Ivano Malavolta
 
Jquery
JqueryJquery
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
Alan Hecht
 
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
Federico Tomassetti
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
Jeremy Kendall
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
musrath mohammad
 
jQuery
jQueryjQuery
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 

What's hot (20)

Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
 
Crowdsourcing with Django
Crowdsourcing with DjangoCrowdsourcing with Django
Crowdsourcing with Django
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Introduction to DBIx::Lite - Kyoto.pm tech talk #2Introduction to DBIx::Lite - Kyoto.pm tech talk #2
Introduction to DBIx::Lite - Kyoto.pm tech talk #2
 
DataMapper @ RubyEnRails2009
DataMapper @ RubyEnRails2009DataMapper @ RubyEnRails2009
DataMapper @ RubyEnRails2009
 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
 
Jquery
JqueryJquery
Jquery
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
jQuery
jQueryjQuery
jQuery
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 

Viewers also liked

Limas 131127003659-phpapp02
Limas 131127003659-phpapp02Limas 131127003659-phpapp02
Limas 131127003659-phpapp02Phond Sarsen
 
The Great War
The Great WarThe Great War
The Great War
almiklas
 
Question 1 media studies evaluation mark final
Question 1 media studies evaluation mark final Question 1 media studies evaluation mark final
Question 1 media studies evaluation mark final salesian2014as
 
6. What have you learnt about technologies from constructing this product?
6. What have you learnt about technologies from constructing this product?6. What have you learnt about technologies from constructing this product?
6. What have you learnt about technologies from constructing this product?
salesian2014as
 
Laptop tune up
Laptop tune upLaptop tune up
Laptop tune up
jennifer_wong
 
GRID Signage: Future of Digital Signage
GRID Signage: Future of Digital SignageGRID Signage: Future of Digital Signage
GRID Signage: Future of Digital Signage
apptividia
 
Presentasi kki12 edit 3 n
Presentasi kki12 edit 3 nPresentasi kki12 edit 3 n
Presentasi kki12 edit 3 n
Icc Fai Umy
 
The making of Lys-de-Membre - Part 1
The making of Lys-de-Membre - Part 1The making of Lys-de-Membre - Part 1
The making of Lys-de-Membre - Part 1
Iris Casteleyn
 
Mark Mulcahy Question 1 media studies evaluation
Mark Mulcahy Question 1 media studies evaluationMark Mulcahy Question 1 media studies evaluation
Mark Mulcahy Question 1 media studies evaluationsalesian2014as
 
Mark Question 3 media studies evaluation
Mark Question 3 media studies evaluationMark Question 3 media studies evaluation
Mark Question 3 media studies evaluationsalesian2014as
 
Mary C6 Evaluation Question 1
Mary C6 Evaluation Question 1Mary C6 Evaluation Question 1
Mary C6 Evaluation Question 1
salesian2014as
 
Beauty Industry Marketing Facts And Trends
Beauty Industry Marketing Facts And Trends Beauty Industry Marketing Facts And Trends
Beauty Industry Marketing Facts And Trends
Illumination Consulting
 

Viewers also liked (16)

Limas 131127003659-phpapp02
Limas 131127003659-phpapp02Limas 131127003659-phpapp02
Limas 131127003659-phpapp02
 
The Great War
The Great WarThe Great War
The Great War
 
Question 1 media studies evaluation mark final
Question 1 media studies evaluation mark final Question 1 media studies evaluation mark final
Question 1 media studies evaluation mark final
 
6. What have you learnt about technologies from constructing this product?
6. What have you learnt about technologies from constructing this product?6. What have you learnt about technologies from constructing this product?
6. What have you learnt about technologies from constructing this product?
 
Laptop tune up
Laptop tune upLaptop tune up
Laptop tune up
 
Evaluation 1
Evaluation 1Evaluation 1
Evaluation 1
 
GRID Signage: Future of Digital Signage
GRID Signage: Future of Digital SignageGRID Signage: Future of Digital Signage
GRID Signage: Future of Digital Signage
 
Presentasi kki12 edit 3 n
Presentasi kki12 edit 3 nPresentasi kki12 edit 3 n
Presentasi kki12 edit 3 n
 
The making of Lys-de-Membre - Part 1
The making of Lys-de-Membre - Part 1The making of Lys-de-Membre - Part 1
The making of Lys-de-Membre - Part 1
 
Mark Mulcahy Question 1 media studies evaluation
Mark Mulcahy Question 1 media studies evaluationMark Mulcahy Question 1 media studies evaluation
Mark Mulcahy Question 1 media studies evaluation
 
Penguasaan bhs
Penguasaan bhsPenguasaan bhs
Penguasaan bhs
 
DPHEP_BLUETWO_001
DPHEP_BLUETWO_001DPHEP_BLUETWO_001
DPHEP_BLUETWO_001
 
Mark Question 3 media studies evaluation
Mark Question 3 media studies evaluationMark Question 3 media studies evaluation
Mark Question 3 media studies evaluation
 
Mary C6 Evaluation Question 1
Mary C6 Evaluation Question 1Mary C6 Evaluation Question 1
Mary C6 Evaluation Question 1
 
Beauty Industry Marketing Facts And Trends
Beauty Industry Marketing Facts And Trends Beauty Industry Marketing Facts And Trends
Beauty Industry Marketing Facts And Trends
 
Presentation1
Presentation1Presentation1
Presentation1
 

Similar to AmdJavaMeetupBDDUsingCucumber

jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Knowgirish82
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
ambiescent
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
Thomas Kjeldahl Nilsson
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsJarod Ferguson
 
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
Guilherme Carreiro
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)David Giard
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
Robert Nyman
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
Ben Lesh
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
Iban Martinez
 
I put on my mink and wizard behat (tutorial)
I put on my mink and wizard behat (tutorial)I put on my mink and wizard behat (tutorial)
I put on my mink and wizard behat (tutorial)
xsist10
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
Jonas De Smet
 
An Introduction to Jquery
An Introduction to JqueryAn Introduction to Jquery
An Introduction to Jquery
Phil Reither
 
How to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrainHow to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrain
Codemotion Tel Aviv
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
Kaz Yoshikawa
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
Mark
 
jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
Allegient
 
JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)
Robert Nyman
 

Similar to AmdJavaMeetupBDDUsingCucumber (20)

jQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't KnowjQuery - 10 Time-Savers You (Maybe) Don't Know
jQuery - 10 Time-Savers You (Maybe) Don't Know
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
TDC 2014 - JavaScript de qualidade: hoje, amanhã e sempre!
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
 
JavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New WorldJavaScript & HTML5 - Brave New World
JavaScript & HTML5 - Brave New World
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Javascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introductionJavascript & jQuery: A pragmatic introduction
Javascript & jQuery: A pragmatic introduction
 
I put on my mink and wizard behat (tutorial)
I put on my mink and wizard behat (tutorial)I put on my mink and wizard behat (tutorial)
I put on my mink and wizard behat (tutorial)
 
jQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and PerformancejQuery: Tips, tricks and hints for better development and Performance
jQuery: Tips, tricks and hints for better development and Performance
 
An Introduction to Jquery
An Introduction to JqueryAn Introduction to Jquery
An Introduction to Jquery
 
How to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrainHow to actually use promises - Jakob Mattsson, FishBrain
How to actually use promises - Jakob Mattsson, FishBrain
 
Idioms in swift 2016 05c
Idioms in swift 2016 05cIdioms in swift 2016 05c
Idioms in swift 2016 05c
 
Building Go Web Apps
Building Go Web AppsBuilding Go Web Apps
Building Go Web Apps
 
jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
 
JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)JavaScript and HTML5 - Brave New World (revised)
JavaScript and HTML5 - Brave New World (revised)
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

AmdJavaMeetupBDDUsingCucumber

  • 1. Behavior Driven Development with Cucumber JVM By Gopal Shah
  • 2. Agenda ● TDD session recap ● BDD solution analysis ● Cucumber features ● Alternative BDD frameworks ● Q & A
  • 3. BDD impact ● Behavior is more useful than “test” ● Ubiquitous language ● Increased collaboration ● Living documentation
  • 4. Cucumber internals ● Gherkin ● Ignores keywords ● Step results → Passed, Failed, Pending, Undefined ● World object
  • 5. Tips & Tricks ● Use capture groups ● Distinguish singular/plural with '?' ● Use non-capturing groups (?:visit|go to) When I visit the homepage When I go to the homepage ● Use anchors (“^ … $”) ● Use tags and folders to organize
  • 6. Use Doc Strings Scenario: Ban Unscrupulous Users When I behave unscrupulously Then I should receive an email containing: """ Dear Sir, Your account privileges have been revoked due to your unscrupulous behavior. Sincerely, The Management """ And my account should be locked
  • 7. Doc Strings Step Defn @When("^I behave unscrupulously$") @Then("^I should receive an email containing:$") public void I_should_receive_an_email_containing(String arg1) throws Throwable { throw new PendingException(); } @Then("^my account should be locked$")
  • 8. Data Tables Scenario: Given a board like this: | | 1 | 2 | 3 | | 1 | | | | | 2 | | | | | 3 | | | | When player x plays in row 2, column 1 Then the board should look like this: | | 1 | 2 | 3 | | 1 | | | | | 2 | x | | | | 3 | | | |
  • 9. Data tables Step Defn @Given("^a board like this:$") public void a_board_like_this(String[][] twoDStringArray) {} @When("^player x plays in row (d+), column (d+)$") public void player_x_plays_in_row_column(int row, int column) {} @Then("^the board should look like this:$") public void the_board_should_look_like_this(String[][] twoDStringArray) {}
  • 10. Scenario Hooks import cucumber.annotation.After; import cucumber.annotation.Before; @Before public void beforeScenario() { tomcat.start(); tomcat.deploy("myapp"); } @After public void afterScenario() { tomcat.stop(); }
  • 11. Tagged Hooks @Before(value = {"@txn"}, order = 100) public void startTransaction() { } @After(value = {"@txn"}, order = 100) public void rollBackTransaction() { } SpringTransactionHooks
  • 12. Global Hooks @Before("@web") public void beforeScenario() { if (!tomcat.isRunning()) { tomcat.start(); tomcat.deploy("myapp"); browser = new FirefoxDriver(); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { browser.close(); tomcat.stop(); } }); } }
  • 13. Features vs Stories Recommended NOT to do the following: features/ story_38971_generate_new_report.feature story_38986_run_report.feature story_39004_log_in.feature
  • 14. How NOT to have bored stakeholders Scenario: Check inbox Given a User "Dave" with password "password" And a User "Sue" with password "secret" And an email to "Dave" from "Sue" When I sign in as "Dave" with password "password" Then I should see 1 email from "Sue" in my inbox
  • 15. Avoid incidental details Scenario: Check inbox Given a User "Dave" And a User "Sue" And an email to "Dave" from "Sue" When I sign in as "Dave" Then I should see 1 email from "Sue" in my inbox
  • 16. Can be further improved ... Scenario: Check inbox Given I have received an email from "Sue" When I sign in Then I should see 1 email from "Sue" in my inbox
  • 17. Imperative steps Feature: Animal Submission As a Zoologist I want to add a new animal to the site So that I can share my animal knowledge with the community Scenario: successful submission Given I'm on the animal creation page When I fill in Name with 'Alligator' And select Phylum as 'Chordata' And fill in Animal Class with 'Sauropsida' And fill in Order with 'Crocodilia' And fill in Family with 'Alligatoridae' And fill in Genus with 'Alligator' And check Lay Eggs And click the Create button Then I should see the notice 'Thank you for your animal submission!' And the page should include the animal's name, phylum, animal class, order, family, and genus
  • 18. Declarative steps Feature: Animal Submission As a Zoologist I want to add a new animal to the site So that I can share my animal knowledge with the community Scenario: successful submission Given I'm on the animal creation page When I add a new animal Then I should see the page for my newly created animal And the notice 'Thank you for your animal submission!'
  • 19. StepDefn for Declarative steps @When("^I add a new animal$") public void I_add_a_new_animal() throws Throwable { fillsIn("Name",with("Alligator")); selects("Chordata"),from("Phylum")); fillsIn("Animal Class",with("Sauropsida")); fillsIn("Order",with("Crocodilia")); fillsIn("Family",with("Alligatoridae")); fillsIn("Genus",with("Alligator")); checks("Lay Eggs"); clicks_button("Create");}
  • 20. Don't make it too declarative … Scenario: The whole system Given the system exists When I use it Then it should work, perfectly
  • 21. Alternative frameworks ● Jbehavior +ve: namedParameters, compositeSteps -ve: DocString, formatting, gherkin standards ● Concordian
  • 22. Composite steps in JBehavior @Given("%customer has previously bought a %product") // used in normal parameter matching @Alias("<customer> has previously bought a <product>") // used in parameterised scenarios @Composite(steps = { "Given <customer> is logged in", "Given <customer> has a cart", "When a <product> is added to the cart" }) public void aCompositeStep(@Named("customer") String customer, @Named("product") String product) { }