SlideShare una empresa de Scribd logo
1 de 52
Behaviour Driven
Development
(BDD)
(AKA Keep BDD Love Alive)
@rorypreddy
Agenda
• Intro
• TDD and BDD
• Tools
–JBehave
–Serenity
• How to Keep BDD Love Alive
A “little” bit about Rory
• Technology Evangelist at BBD
– www.bbd.co.za
• Organizer for Jozi-JUG and Joburg AWS User
Forum (AWS-Jozi)
• Not related to Tyrion Lannister
• Don’t do kids parties
SENDER
Step 1: Make an appointment
“I would like to Dialogue about
something.
Is now OK?”
Step 2: The Send
“I feel…”, “I tell myself…”,
“My desire is…”
Step 3: The Summary
“You got it all”
RECEIVER
Step 1: Agree to the
appointment
“I’m available now”
Step 2: The Mirror and the
Check
I heard you say…, You said…
Step 3: The Summary
“Am I getting you? Did I get all
of that?”
Agenda
• Intro
• TDD and BDD
• Tools
–JBehave
–Serenity
• How to Keep BDD Love Alive
BDD is about having conversations
BDD should make it easy to create software
A scenario is an idea, not a promise
So BDD is…
• An evolution of Test Driven
Development
• Created by Dan North in 2003:
“Programmers wanted to know where to
start, what to test and what not to test,
how much to test in one go, what to call
their tests, and how to understand why a
test fails.”
BDD
Given- Set of
preconditions
Then-Some
testable outcome
When-When a
event occurs
Uses Given-Then-When (Gherkin)
Lets define ATDD and TDD
ATDD
FitNesse
Spectacular
Concordian
Serenity
BDD
SpecFlow
Cucumber
JBehave
NBehave
Behat
TDD
JUnit
NUnit
TestNG
MSTest
Test Driven Development (TDD)
Kent Beck defines:
• Never write a single line of code unless you have a failing
automated test.
• Eliminate duplication.
• Red (Automated test fail)
• Green (test pass)
• Refactor (Clean the code)
RED
GREENREFACTOR
TDD
BDD
Write an
acceptance
test
Run the
acceptance
test
Create
software
Acceptance Test Driven Development
= BDD combined with TDD
Create
software
Make the
test pass
REFACTOR
TDD
Write a
failing
test
+ Verification
Agenda
• Intro
• TDD and BDD
• Tools
–JBehave
–Serenity
• How to Keep BDD Love Alive
JBehave
• Created by Dan North in 2003
• Original BDD framework
• Great Tooling and IDE plugins
• Uses Given/Then/When in plain text
• Decision tables
–we know you love excel
Write a Story
Given a shopping cart
When one item is added
Then the cart should have 1 items in it
…
Map Steps to Code
@Given("a shopping cart")
public void aCart() {
cart = new ShoppingCart();
}
@When("one item is added")
public void addAnItem() {
cart.getItems().add(new Item("Juice", Item.SHELF.TOP));
}
@Then("the cart should have $numberOfItems items in it")
public void checkItemsSaved(int numberOfItems) {
assertEquals(numberOfItems, cart.getItems().size());
}
Run Stories
Demo
Given a shopping cart
When there is help for a hard to reach item
Then help should give me that item
Examples:
|itemName|shelf|help
|Eggs|BOTTOM|true
|tabasco|MIDDLE|true
|Juice|TOP|false
Tools
ATDD
FitNesse
Spectacular
Concordian
Serenity
BDD
SpecFlow
Cucumber
JBehave
NBehave
Behat
TDD
JUnit
NUnit
TestNG
MSTest
Self-
documenting
SeleniumJBehave
with JUnit
Layered
BDD
Serenity
(Thucydides)
Goals
Tasks
Interactions
Feature:
Rory
thinks
Add new todos
needs to be able to jot down actions he needs to do as he
of them
Scenario: Record a new todo action
to buy
for future use
Given Rory needs some milk
When Rory adds the todo action 'Bu
y
som
e
milk'
Then 'Buy some milk' should be recorded in his todo list
A goal
A task
@Steps ATodoUser rory;
@When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$")
public void i_add_the_todo_action(String actionName) {
rory.adds_an_action_called(actionName);
} The task definition
TodoPage onTheTodoHomePage
; An interaction
@Step
public void adds_an_action_called(String actionName) {
onTheTodoHomePage.addAnActionCalled(actionName);
}
The Serenity layered architecture
Feature: Add new todos
I need to be able to jot down actions I need to do as fast as I think of them
Scenario:
Given I
Record a new todo action for future use
need to buy some milk
When I add the todo action 'Buy some milk'
Then 'Buy some milk' should be recorded in my todo list
Serenity documentation
Demo Time!
Given I need to <definition1>
When I add the todo action "<action1>"
Then "<action1>" should be recorded in my todo list
Examples:
|definition1|action1
|buy some milk|Buy some milk
|buy some sugar|Buy some sugar
Highly readable
style
Encourages reuse
and maintainable
code
Small, reusable
interaction
components
User-centric
Why is Serenity Different?
-The Journey Pattern
Meet Rory
Journey Pattern
-An Actor
Actors have goals
Given Rory needs to buy some milk
When Rory adds the todo action 'Buy some milk'
Then 'Buy some milk' should be recorded in his todo list
I’d like to be able to recall
all the things I need to do
Journey Pattern
Actors have abilities I can browse the web with my
browser
Journey Pattern
Actor rory = Actor.named(“Rory");
@Managed
WebDriver hisBrowser;
…
rory.can(BrowseTheWeb.with(hisBrowser));
I’ll add ‘Buy some milk’ to
my todo list
Actors perform tasks
Journey Pattern
@Steps
AddItem addATodoItem;
…
rory.attemptsTo(addATodoItem.called("Buy some milk"));
Actors may interact with the system to
perform these tasks
Type ‘Buy the milk’
Press ‘ENTER’
Journey Pattern
Journey Pattern
Goals
Elements ScreenActor Tasks
ActionsAbilities
have About the state of
On a
Interact with
enable
Made up of
Performs
has
PageObject Pattern
DesiredCapabilites desiredCapabilities= new DesiredCapabilites();
WebDriver driver = new PhantomJSDriver(desiredCapabilities());
driver.get(baseUrl+"owners/find.html");
FindOwnersPage findOwners = PageFactory.initElements(driver,
FindOwnersPage.class);
OwnersPage owners = findOwners.findWith(EMPTY_SEARCH_TERMS);
assertThat(owners.numberOfOwners(), is(10);
Journey Pattern
Actor theReceptionist = new Actor().with(WebBrowsing.ability();
theReceptionist.attemptsTo(
Go.to(findOwnersScreeen.url),
Search.forOwnersWith(EMPTY_SEARCH_TERMS),
Count.theNumberOfOwners()
);
assertThat(
theReceptionist.sawThatThe(numberOfOwners()),
was(theExpectedNumberOfOwners)
);
Jenkins
(Continuous Integration)
JIRA
Agenda
• Intro
• TDD and BDD
• Tools
–JBehave
–Serenity
• How to Keep BDD Alive
We have large BDD suites written in a Cucumber Clone
• They spend much of their life red
Customers don’t engage with our BDD suites
• And yet we spend a lot of time maintaining them
Our BDD suites are slow to run and increase the cost
of the “check-in dance”
• Developers start ignoring red results
• And we have to down tools to fix them
Developers don’t want to write them
• Because they can’t see the value return on their
effort
• They just want to build software
BDD Counselling
How to Keep BDD Alive
• Don’t Skip the conversation
• Involve the whole team
• Use Journeys not Events
• Accept you’ll still miss things
How to Keep BDD Love Alive
• Work on it - don’t rely on “magic”.
• “Its 50% your responsibility”
• Avoid
–Criticism
–Contempt
–Defensiveness
–Stonewalling
What did We Learn?
• What is BDD
• Tools
–JBehave
–Serenity
• How to Keep BDD Love Alive
• Lookout!
–Shameless User Group Plug coming up…
 AWS-JOZI - www.meetup.com/AWS-JOZI
 New AWS centric User group
 Top notch venues
 Jozi-JUG - www.meetup.com/Jozi-JUG
 2000 members
 Sessions of +200 attendees
 Conferences and monthly meetups
 Venues rotate around Johannesburg
&
Self Social
Mentorship
Community
Culture
Experience
Relevance
Education
Career
Questions
@rorypreddy
• https://github.com/roryp/jbehave-tutorial
• https://github.com/roryp/jbehave-webtest-todomvc

Más contenido relacionado

Destacado

Risks and strategies adopting agile in medium and large organizations
Risks and strategies adopting agile in medium and large organizationsRisks and strategies adopting agile in medium and large organizations
Risks and strategies adopting agile in medium and large organizations
Agile Software Community of India
 
Bab 09 kekuatan sambungan las
Bab 09 kekuatan sambungan lasBab 09 kekuatan sambungan las
Bab 09 kekuatan sambungan las
Rumah Belajar
 

Destacado (12)

SUGSA JHB 10 Agile anti-patterns in distributed teams 2014 - Pavel Dabrytski
SUGSA JHB 10 Agile anti-patterns in distributed teams 2014 - Pavel DabrytskiSUGSA JHB 10 Agile anti-patterns in distributed teams 2014 - Pavel Dabrytski
SUGSA JHB 10 Agile anti-patterns in distributed teams 2014 - Pavel Dabrytski
 
Agile Anti-patterns
Agile Anti-patternsAgile Anti-patterns
Agile Anti-patterns
 
Coaching Anti-Pattens and common smells
 Coaching Anti-Pattens and common smells Coaching Anti-Pattens and common smells
Coaching Anti-Pattens and common smells
 
Agile Anti-Patterns. Yes your agile projects can and will fail too.
Agile Anti-Patterns. Yes your agile projects can and will fail too.Agile Anti-Patterns. Yes your agile projects can and will fail too.
Agile Anti-Patterns. Yes your agile projects can and will fail too.
 
Risks and strategies adopting agile in medium and large organizations
Risks and strategies adopting agile in medium and large organizationsRisks and strategies adopting agile in medium and large organizations
Risks and strategies adopting agile in medium and large organizations
 
Overcome the 6 Antipatterns of Agile Adoption
Overcome the 6 Antipatterns of Agile AdoptionOvercome the 6 Antipatterns of Agile Adoption
Overcome the 6 Antipatterns of Agile Adoption
 
ScrumDay Vietnam 2012 - Agile adoption - Nhan
ScrumDay Vietnam 2012 - Agile adoption - NhanScrumDay Vietnam 2012 - Agile adoption - Nhan
ScrumDay Vietnam 2012 - Agile adoption - Nhan
 
User Story Smells & Anti-patterns
User Story Smells & Anti-patternsUser Story Smells & Anti-patterns
User Story Smells & Anti-patterns
 
Agile Adoption Patterns And Antipatterns
Agile Adoption Patterns And AntipatternsAgile Adoption Patterns And Antipatterns
Agile Adoption Patterns And Antipatterns
 
Polyglot
PolyglotPolyglot
Polyglot
 
Vs java (1)
Vs java (1)Vs java (1)
Vs java (1)
 
Bab 09 kekuatan sambungan las
Bab 09 kekuatan sambungan lasBab 09 kekuatan sambungan las
Bab 09 kekuatan sambungan las
 

Similar a BDD - Keep love alive

Behavior Driven Development: An Overview
Behavior Driven Development:  An OverviewBehavior Driven Development:  An Overview
Behavior Driven Development: An Overview
bmaynard_at_litle
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development present
Raul Panjiyar
 

Similar a BDD - Keep love alive (20)

BDD testing with cucumber
BDD testing with cucumberBDD testing with cucumber
BDD testing with cucumber
 
API Simplicity + Consistency == Speed: Designing APIs That Are Easy and Fun t...
API Simplicity + Consistency == Speed: Designing APIs That Are Easy and Fun t...API Simplicity + Consistency == Speed: Designing APIs That Are Easy and Fun t...
API Simplicity + Consistency == Speed: Designing APIs That Are Easy and Fun t...
 
Is Your API Misbehaving (workshop)
Is Your API Misbehaving (workshop)Is Your API Misbehaving (workshop)
Is Your API Misbehaving (workshop)
 
BDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and BehatBDD API Tests with Gherkin and Behat
BDD API Tests with Gherkin and Behat
 
Behavior Driven Development: An Overview
Behavior Driven Development:  An OverviewBehavior Driven Development:  An Overview
Behavior Driven Development: An Overview
 
Rubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDDRubyconf2016 - Solving communication problems in distributed teams with BDD
Rubyconf2016 - Solving communication problems in distributed teams with BDD
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
Behat for writing tests in a stylized way
Behat for writing tests in a stylized wayBehat for writing tests in a stylized way
Behat for writing tests in a stylized way
 
api-driven-development.pdf
api-driven-development.pdfapi-driven-development.pdf
api-driven-development.pdf
 
Object Oriented Views / Aki Salmi
Object Oriented Views / Aki SalmiObject Oriented Views / Aki Salmi
Object Oriented Views / Aki Salmi
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
Gaej For Beginners
Gaej For BeginnersGaej For Beginners
Gaej For Beginners
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Behaviour driven development present
Behaviour driven development presentBehaviour driven development present
Behaviour driven development present
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have known
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
 

Más de Rory Preddy

Más de Rory Preddy (17)

Programming for accessibility
Programming for accessibilityProgramming for accessibility
Programming for accessibility
 
Whats new in .net for 2019
Whats new in .net for 2019Whats new in .net for 2019
Whats new in .net for 2019
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019
 
Getting started with Firebase
Getting started with FirebaseGetting started with Firebase
Getting started with Firebase
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12
 
AWS for Java Developers workshop
AWS for Java Developers workshopAWS for Java Developers workshop
AWS for Java Developers workshop
 
Java modules
Java modulesJava modules
Java modules
 
Java 2018 certifications
Java 2018 certificationsJava 2018 certifications
Java 2018 certifications
 
AWS Transcribe and Comprehend
AWS Transcribe and ComprehendAWS Transcribe and Comprehend
AWS Transcribe and Comprehend
 
BDD with Mockito
BDD with MockitoBDD with Mockito
BDD with Mockito
 
Up and Running with Kubernetes
Up and Running with KubernetesUp and Running with Kubernetes
Up and Running with Kubernetes
 
Dockercompose
DockercomposeDockercompose
Dockercompose
 
Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5Functional Reactive Endpoints using Spring 5
Functional Reactive Endpoints using Spring 5
 
AWS and Serverless with Alexa
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with Alexa
 
Nashorn
NashornNashorn
Nashorn
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java Developer
 
Kotlin
KotlinKotlin
Kotlin
 

Último

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

BDD - Keep love alive

  • 1. Behaviour Driven Development (BDD) (AKA Keep BDD Love Alive) @rorypreddy
  • 2. Agenda • Intro • TDD and BDD • Tools –JBehave –Serenity • How to Keep BDD Love Alive
  • 3. A “little” bit about Rory • Technology Evangelist at BBD – www.bbd.co.za • Organizer for Jozi-JUG and Joburg AWS User Forum (AWS-Jozi) • Not related to Tyrion Lannister • Don’t do kids parties
  • 4.
  • 5. SENDER Step 1: Make an appointment “I would like to Dialogue about something. Is now OK?” Step 2: The Send “I feel…”, “I tell myself…”, “My desire is…” Step 3: The Summary “You got it all” RECEIVER Step 1: Agree to the appointment “I’m available now” Step 2: The Mirror and the Check I heard you say…, You said… Step 3: The Summary “Am I getting you? Did I get all of that?”
  • 6.
  • 7. Agenda • Intro • TDD and BDD • Tools –JBehave –Serenity • How to Keep BDD Love Alive
  • 8.
  • 9. BDD is about having conversations BDD should make it easy to create software A scenario is an idea, not a promise
  • 10. So BDD is… • An evolution of Test Driven Development • Created by Dan North in 2003: “Programmers wanted to know where to start, what to test and what not to test, how much to test in one go, what to call their tests, and how to understand why a test fails.”
  • 11. BDD Given- Set of preconditions Then-Some testable outcome When-When a event occurs Uses Given-Then-When (Gherkin)
  • 12.
  • 13. Lets define ATDD and TDD ATDD FitNesse Spectacular Concordian Serenity BDD SpecFlow Cucumber JBehave NBehave Behat TDD JUnit NUnit TestNG MSTest
  • 14. Test Driven Development (TDD) Kent Beck defines: • Never write a single line of code unless you have a failing automated test. • Eliminate duplication. • Red (Automated test fail) • Green (test pass) • Refactor (Clean the code) RED GREENREFACTOR TDD
  • 15. BDD Write an acceptance test Run the acceptance test Create software Acceptance Test Driven Development = BDD combined with TDD Create software Make the test pass REFACTOR TDD Write a failing test + Verification
  • 16.
  • 17. Agenda • Intro • TDD and BDD • Tools –JBehave –Serenity • How to Keep BDD Love Alive
  • 18. JBehave • Created by Dan North in 2003 • Original BDD framework • Great Tooling and IDE plugins • Uses Given/Then/When in plain text • Decision tables –we know you love excel
  • 19. Write a Story Given a shopping cart When one item is added Then the cart should have 1 items in it …
  • 20. Map Steps to Code @Given("a shopping cart") public void aCart() { cart = new ShoppingCart(); } @When("one item is added") public void addAnItem() { cart.getItems().add(new Item("Juice", Item.SHELF.TOP)); } @Then("the cart should have $numberOfItems items in it") public void checkItemsSaved(int numberOfItems) { assertEquals(numberOfItems, cart.getItems().size()); }
  • 22.
  • 23.
  • 24.
  • 25. Demo Given a shopping cart When there is help for a hard to reach item Then help should give me that item Examples: |itemName|shelf|help |Eggs|BOTTOM|true |tabasco|MIDDLE|true |Juice|TOP|false
  • 26.
  • 29. Feature: Rory thinks Add new todos needs to be able to jot down actions he needs to do as he of them Scenario: Record a new todo action to buy for future use Given Rory needs some milk When Rory adds the todo action 'Bu y som e milk' Then 'Buy some milk' should be recorded in his todo list A goal A task @Steps ATodoUser rory; @When(“^(?:.*) (?:adds|has added) the todo action '(.*)'$") public void i_add_the_todo_action(String actionName) { rory.adds_an_action_called(actionName); } The task definition TodoPage onTheTodoHomePage ; An interaction @Step public void adds_an_action_called(String actionName) { onTheTodoHomePage.addAnActionCalled(actionName); } The Serenity layered architecture
  • 30. Feature: Add new todos I need to be able to jot down actions I need to do as fast as I think of them Scenario: Given I Record a new todo action for future use need to buy some milk When I add the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in my todo list Serenity documentation
  • 31.
  • 32. Demo Time! Given I need to <definition1> When I add the todo action "<action1>" Then "<action1>" should be recorded in my todo list Examples: |definition1|action1 |buy some milk|Buy some milk |buy some sugar|Buy some sugar
  • 33. Highly readable style Encourages reuse and maintainable code Small, reusable interaction components User-centric Why is Serenity Different? -The Journey Pattern
  • 35. Actors have goals Given Rory needs to buy some milk When Rory adds the todo action 'Buy some milk' Then 'Buy some milk' should be recorded in his todo list I’d like to be able to recall all the things I need to do Journey Pattern
  • 36. Actors have abilities I can browse the web with my browser Journey Pattern Actor rory = Actor.named(“Rory"); @Managed WebDriver hisBrowser; … rory.can(BrowseTheWeb.with(hisBrowser));
  • 37. I’ll add ‘Buy some milk’ to my todo list Actors perform tasks Journey Pattern @Steps AddItem addATodoItem; … rory.attemptsTo(addATodoItem.called("Buy some milk"));
  • 38. Actors may interact with the system to perform these tasks Type ‘Buy the milk’ Press ‘ENTER’ Journey Pattern
  • 39. Journey Pattern Goals Elements ScreenActor Tasks ActionsAbilities have About the state of On a Interact with enable Made up of Performs has
  • 40. PageObject Pattern DesiredCapabilites desiredCapabilities= new DesiredCapabilites(); WebDriver driver = new PhantomJSDriver(desiredCapabilities()); driver.get(baseUrl+"owners/find.html"); FindOwnersPage findOwners = PageFactory.initElements(driver, FindOwnersPage.class); OwnersPage owners = findOwners.findWith(EMPTY_SEARCH_TERMS); assertThat(owners.numberOfOwners(), is(10); Journey Pattern Actor theReceptionist = new Actor().with(WebBrowsing.ability(); theReceptionist.attemptsTo( Go.to(findOwnersScreeen.url), Search.forOwnersWith(EMPTY_SEARCH_TERMS), Count.theNumberOfOwners() ); assertThat( theReceptionist.sawThatThe(numberOfOwners()), was(theExpectedNumberOfOwners) );
  • 41.
  • 43. JIRA
  • 44. Agenda • Intro • TDD and BDD • Tools –JBehave –Serenity • How to Keep BDD Alive
  • 45.
  • 46. We have large BDD suites written in a Cucumber Clone • They spend much of their life red Customers don’t engage with our BDD suites • And yet we spend a lot of time maintaining them Our BDD suites are slow to run and increase the cost of the “check-in dance” • Developers start ignoring red results • And we have to down tools to fix them Developers don’t want to write them • Because they can’t see the value return on their effort • They just want to build software BDD Counselling
  • 47. How to Keep BDD Alive • Don’t Skip the conversation • Involve the whole team • Use Journeys not Events • Accept you’ll still miss things
  • 48. How to Keep BDD Love Alive • Work on it - don’t rely on “magic”. • “Its 50% your responsibility” • Avoid –Criticism –Contempt –Defensiveness –Stonewalling
  • 49.
  • 50. What did We Learn? • What is BDD • Tools –JBehave –Serenity • How to Keep BDD Love Alive • Lookout! –Shameless User Group Plug coming up…
  • 51.  AWS-JOZI - www.meetup.com/AWS-JOZI  New AWS centric User group  Top notch venues  Jozi-JUG - www.meetup.com/Jozi-JUG  2000 members  Sessions of +200 attendees  Conferences and monthly meetups  Venues rotate around Johannesburg & Self Social Mentorship Community Culture Experience Relevance Education Career