SlideShare ist ein Scribd-Unternehmen logo
1 von 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 …

Weitere ähnliche Inhalte

Kürzlich hochgeladen

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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
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
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Kürzlich hochgeladen (20)

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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
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
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

Empfohlen

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
 

Empfohlen (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.

Hinweis der Redaktion

  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.