SlideShare a Scribd company logo
1 of 19
Aligning Engineering with Business
Value through BDD
Devesh Chanchlani
Test-driven Development
• The code should be tested.
• Each unit of code should be covered by test.
• Each unit of code should be driven by test.
(TDD)
• Architecture should be arrived through
Continuous Design following TDD.
TDD Work Flow
UT

Code Module 1

UT
Integration
Tests

UT
UT

UT

UT

Code Module 2
Challenges of the Approach
•
•
•
•
•
•
•

Where to start?
What to test?
Scope ?
What NOT to test?
How much to test?
How to name your tests?
Intent ?
Understanding why tests fail?
How would the current code bit
Assumption
fit in the bigger picture?
Driven
Scope

Intent /
Motivation
Client Driven

Intended
Behaviour
BDD Work Flow
1. Pick a User-Story
2. Specify a Scenario for the User-Story
3. Run the Scenario and watch it fail
a) Specify behaviour of the component of the system, in the
form of an Example
b) Run the example and watch it fail
c) Implement minimum functionality to make the example
pass
4. Run the scenario, and if it fails, continue with (a)
5. Write another Scenario
BDD Work Flow Example
User-Story:
As a Bank Manager
I want to offer reward points to the Credit Card customers
So that they feel being valued, and can use the reward
points to order various gifts from the shopping portal.

Example:
Amount Points
0

99

0

100
Scenario :
Given a credit card customer
When I spend <amount> from my credit card monthly
Then I should get <points> reward points.

0

1

999

9

1000

10

1001

10

1500

15

9999

99

10000

100
Test Story “RewardPoints.story”
Scenario: Amount Spent Rs.0
Given a credit card customer
When spends 0 from my credit card monthly
Then should get 0 reward points.
Scenario: Amount Spent Rs.9999
Given a credit card customer
When spends 9999 from my credit card monthly
Then should get 99 reward points.
Steps
import
import
import
import
import

org.jbehave.core.annotations.Given;
org.jbehave.core.annotations.Named;
org.jbehave.core.annotations.Then;
org.jbehave.core.annotations.When;
org.jbehave.core.steps.Steps;

public class ExampleSteps extends Steps {
Customer customer;
int amount;
@Given("a credit card customer ")
public void givenCustomer() {
customer = new Customer();
}
@When("spends $amt from my credit card monthly ")
public void spendsAmountBy(@Named(“amt") int amount) {
customer.setExpenditure(amount);
}
@Then(" should get $points reward points ")
public void thenShouldGetPoints(@Named(“points") int points) {
if(customer.getPointsAccrued() != points)
throw new RuntimeException(“Customer points wrongly calculated”);
}
}
Test Execution
import java.util.Arrays;
import java.util.List;
import org.jbehave.core.embedder.Embedder;
public class SimpleJBehave {
private static Embedder embedder = new Embedder();
private static List<String> storyPaths = Arrays
.asList(“bank/creditcard/simplejbehave/RewardPoints.story");
public static void main(String[] args) {
embedder.candidateSteps().add(new ExampleSteps());
embedder.runStoriesAsPaths(storyPaths);
}
}
The New Approach …
UT

Code Module 1

UT

Integration
(Behaviour)
Test

UT
UT

UT
Code Module 2

Feature

UT
Contrasting BDD & TDD
Thinking in Behavioural Terms
TDD

 testZeroBill
 testRewardPointsRoundingOff
 testRewardPointsCalculation

BDD
 should reward no points when bill is 0
 should round off reward points to the floor value
 should reward 1 point on every Rs.100 spent

Benefits of thinking in “behaviour”:
 What to call your test is easy
 How much to test becomes clear
 Reason of a test failure becomes clearly evident
BDD is still TDD
•
•
•
•

Red-Green-Refactor
Test-first programming
Design principles and practices
Micro-incremental design

BDD covers more ground than TDD, although TDD is at its core.

BDD is Second-generation Agile methodology, based on
• Extreme Programming
• Lean Software Development
BDD is Multi-Scale
Specifications can be described at multiple levels
 Top-level can focus on user-interaction
 Further down can focus on affected areas that fulfil
the higher levels expectations
 Even lower we can focus on technical
implementation, still with a solid focus on the
behaviour
Outside-In, Pull-Based
TDD
UT

UT

UT

UT

UT

Integration
Tests

UT

Integration
(Behaviour)
Test

UT
UT
UT

UT
Feature

UT

Inside-Out, Push-based

UT

Outside-In, Pull-based
Assumption Driven
o Need substantial upfront-design in some kind of modelling tool
o Causes waste by decreasing accuracy and increasing rework
o Developer may develop more than what the app needed, or miss
what was actually required.
V/S

Client Driven
o Forces the developer to prove the value of the design by
experiencing it first
o Focussed on what you are actually developing
o Implement exactly what is needed
 BDD creates more harmony between the user story and the
Test-Driven Development.
 The user stories practices represent analysis and specification
in agile projects and TDD represents software design.

 Using BDD, devs are able to best consider the interface from
the perspective of the consumer of the service rather than as
the producer.
 BDD aims to bridge the gap between the differing views of
computer systems held by Business users and Technologists.
Questions …

More Related Content

Recently uploaded

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Aligning Engineering with Business Value through BDD

  • 1. Aligning Engineering with Business Value through BDD Devesh Chanchlani
  • 2. Test-driven Development • The code should be tested. • Each unit of code should be covered by test. • Each unit of code should be driven by test. (TDD) • Architecture should be arrived through Continuous Design following TDD.
  • 3. TDD Work Flow UT Code Module 1 UT Integration Tests UT UT UT UT Code Module 2
  • 4. Challenges of the Approach • • • • • • • Where to start? What to test? Scope ? What NOT to test? How much to test? How to name your tests? Intent ? Understanding why tests fail? How would the current code bit Assumption fit in the bigger picture? Driven
  • 6. BDD Work Flow 1. Pick a User-Story 2. Specify a Scenario for the User-Story 3. Run the Scenario and watch it fail a) Specify behaviour of the component of the system, in the form of an Example b) Run the example and watch it fail c) Implement minimum functionality to make the example pass 4. Run the scenario, and if it fails, continue with (a) 5. Write another Scenario
  • 7. BDD Work Flow Example User-Story: As a Bank Manager I want to offer reward points to the Credit Card customers So that they feel being valued, and can use the reward points to order various gifts from the shopping portal. Example: Amount Points 0 99 0 100 Scenario : Given a credit card customer When I spend <amount> from my credit card monthly Then I should get <points> reward points. 0 1 999 9 1000 10 1001 10 1500 15 9999 99 10000 100
  • 8. Test Story “RewardPoints.story” Scenario: Amount Spent Rs.0 Given a credit card customer When spends 0 from my credit card monthly Then should get 0 reward points. Scenario: Amount Spent Rs.9999 Given a credit card customer When spends 9999 from my credit card monthly Then should get 99 reward points.
  • 9. Steps import import import import import org.jbehave.core.annotations.Given; org.jbehave.core.annotations.Named; org.jbehave.core.annotations.Then; org.jbehave.core.annotations.When; org.jbehave.core.steps.Steps; public class ExampleSteps extends Steps { Customer customer; int amount; @Given("a credit card customer ") public void givenCustomer() { customer = new Customer(); } @When("spends $amt from my credit card monthly ") public void spendsAmountBy(@Named(“amt") int amount) { customer.setExpenditure(amount); } @Then(" should get $points reward points ") public void thenShouldGetPoints(@Named(“points") int points) { if(customer.getPointsAccrued() != points) throw new RuntimeException(“Customer points wrongly calculated”); } }
  • 10. Test Execution import java.util.Arrays; import java.util.List; import org.jbehave.core.embedder.Embedder; public class SimpleJBehave { private static Embedder embedder = new Embedder(); private static List<String> storyPaths = Arrays .asList(“bank/creditcard/simplejbehave/RewardPoints.story"); public static void main(String[] args) { embedder.candidateSteps().add(new ExampleSteps()); embedder.runStoriesAsPaths(storyPaths); } }
  • 11. The New Approach … UT Code Module 1 UT Integration (Behaviour) Test UT UT UT Code Module 2 Feature UT
  • 13. Thinking in Behavioural Terms TDD  testZeroBill  testRewardPointsRoundingOff  testRewardPointsCalculation BDD  should reward no points when bill is 0  should round off reward points to the floor value  should reward 1 point on every Rs.100 spent Benefits of thinking in “behaviour”:  What to call your test is easy  How much to test becomes clear  Reason of a test failure becomes clearly evident
  • 14. BDD is still TDD • • • • Red-Green-Refactor Test-first programming Design principles and practices Micro-incremental design BDD covers more ground than TDD, although TDD is at its core. BDD is Second-generation Agile methodology, based on • Extreme Programming • Lean Software Development
  • 15. BDD is Multi-Scale Specifications can be described at multiple levels  Top-level can focus on user-interaction  Further down can focus on affected areas that fulfil the higher levels expectations  Even lower we can focus on technical implementation, still with a solid focus on the behaviour
  • 17. Assumption Driven o Need substantial upfront-design in some kind of modelling tool o Causes waste by decreasing accuracy and increasing rework o Developer may develop more than what the app needed, or miss what was actually required. V/S Client Driven o Forces the developer to prove the value of the design by experiencing it first o Focussed on what you are actually developing o Implement exactly what is needed
  • 18.  BDD creates more harmony between the user story and the Test-Driven Development.  The user stories practices represent analysis and specification in agile projects and TDD represents software design.  Using BDD, devs are able to best consider the interface from the perspective of the consumer of the service rather than as the producer.  BDD aims to bridge the gap between the differing views of computer systems held by Business users and Technologists.

Editor's Notes

  1. Start by scrubbing the behaviour of the whole application, and continue by specifying the individual parts needed for this behaviour.This approach is called “Outside-In” approach.