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

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Recently uploaded (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
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
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
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
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

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.