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

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Kürzlich hochgeladen (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

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.