SlideShare a Scribd company logo
Star Trek:

BDD Enterprise
Tomek Dubikowski
let’s have a small trip around the universe
every ship needs 

a captain
ready? steady?

go
first stop

planet chaos
technology and business
don’t talk at all
requirements hell
tech people business
second stop

planet waterfall
the silos kingdom
the dark lords
documentation is the main
source of knowledge
CR - 271
CR - 228
CR - 419
CR - 56
CR - 94
CR - 382
CR - 253
CR - 212
CR - 199
CR - 158
what if I told you that you can know
how the system works based on
how it actually works?
third stop

planet agile
working software over comprehensive
documentation
test scenario describes system behavior
green test means that system
actually behaves as described
red test means that system
doesn’t behave as described
tests vs documentation
fourth stop

BDD moon
beer 

driven 

development
behavior driven development
think how
your system
should
behave
create test
scenario for
the behavior
development
team
implements
the behavior
ok, genius
wait a minute
given – when – then
not sure if BDD
is not just TDD
@Test
public void
shouldDoSomethingWhenSomething() {
// given
...
// when
...
// then
...
}
my unit tests are like that
BDD is like TDD if…
BDD
TDD
test first
unit testing
• analysis
• design
• code / test
• code / test
think how
your system
should
behave
create test
scenario for
the behavior
development
team
implements
the behavior
i do the same stuff in excel
where is the difference
where is the difference
aww, but this is technical stuff
aww, but this is technical stuff
unit
integration
system
a little twist
story
file
Narrative:
As account user I want to make money transfer on my account
Scenario: Outgoing transfer from user account
Given: User has 100$ on his account
When: User makes a 50$ transfer to another account
Then: User has 50$ on his account
And: Another account state has increased by 50$
a little twist
story
file
reports = current documentation
green
systems
behaves like
described in
scenario
use the right tools
story
file
code file
how (most of) these work
implements
two files to maintain
high coupling
@Then("the value returned is empty")
public void theValueIsEmpty() {
...
}
@Then("the value returned is $value")
public void theValueIs(String value) {
...
}
the actual code
regex matching
jre
dependent
IDE integration is a pain
heavyweight players
only for system test level
hello again, captain spock
use spock, it’s better
groovy is groovy because:
• dynamic language
• functional style
• easy for java developers
• syntax boosts
• syntax simplifications
powerful for DSLs
even spock’s syntax is DSL
business use case
Narrative:
Customers do the shopping in our shop. When he checks out we
need to calculate the right delivery charge depending on the
total value of the basket, delivery date and if customer has
bought delivery subscription.
Scenario: Shopping for more than 40£ should not be charged
Given: Customer has products for 50£ in the basket
When: Customer checks out
Then: No delivery charge is added to the receipt
And: Email with receipt is sent to the customer
let’s migrate it to spock
Narrative:
Customers do the shopping in our shop. When he checks out we
need to calculate the right delivery charge depending on the
total value of the basket, delivery date and if customer has
bought delivery subscription.
@Narrative(‘’’
Customers do the shopping in our shop. When he checks out we
need to calculate the right delivery charge depending on the
total value of the basket, delivery date and if customer has
bought delivery subscription.
‘’’)
@Title(‘Delivery charge specification’)
@Narrative(‘’’
Customers do the shopping in our shop. When he checks out we
need to calculate the right delivery charge depending on the
total value of the basket, delivery date and if customer has
bought delivery subscription.
‘’’)
class DeliveryChargeTest extends Specification {
first things first – narrative
not that technical
Scenario: Shopping for more than 40£ should not be charged
Given: Customer has products for 50£ in the basket
When: Customer checks out
Then: No delivery charge is added to the receipt
And: Email with receipt is sent to the customer
second step – scenario
def ‘Shopping for more than 40£ should not be
charged’ () {
given: ‘Customer has products for 50£ in the basket’
when: ‘Customer checks out’
then: ‘No delivery charge is added to the receipt’
and: ‘Email with receipt is sent to the customer’
}
def ‘Shopping for more than 40£ should not be
charged’ () {
given: ‘Customer has products for 50£ in the basket’
<code>
when: ‘Customer checks out’
<code>
then: ‘No delivery charge is added to the receipt’
<code>
and: ‘Email with receipt is sent to the customer’
<code>
}
def ‘Shopping for more than 40£ should not be charged’ () {
given: ‘Customer has products for 50£ in the basket’
Customer customer = aCustomer.withBasket(aBasket.with(...)).build();
when: ‘Customer checks out’
Order order = customer.checkOut(new Date());
then: ‘No delivery charge is added to the receipt’
assertThat(order.getDeliveryCharge()).isEqualTo(0);
and: ‘Email with receipt is sent to the customer’
verify(emailService).sendMessage(customer.getEmailAddres(),
anyMessage())
}
give me a try, please
def ‘Shopping for more than 40£ should not be charged’ () {
given: ‘Customer has products for 50£ in the basket’
Customer customer = aCustomerWith50PoundsWorthBakset();
when: ‘Customer checks out’
Order order = chechout(customer);
then: ‘No delivery charge is added to the receipt’
assertThatDeliveryChargeIsZero(order);
and: ‘Email with receipt is sent to the customer’
verifyThatEmailWasSentTo(customer);
}
def ‘Shopping for more than 40£ should not be charged’ () {
given: ‘Customer has products for 50£ in the basket’
def customer = ‘a customer with 50£ worth basket’()
when: ‘Customer checks out’
def order = checkout customer
then: ‘No delivery charge is added to the receipt’
‘delivery charge of’ order == 0
and: ‘Email with receipt is sent to the customer’
‘email was sent to’ customer
}
def ‘Shopping for more than 40£ should not be charged’ () {
given: ‘Customer has products for 50£ in the basket’
customer with basket of value 50
when: ‘Customer checks out’
customer checkouts order
then: ‘No delivery charge is added to the receipt’
delivery charge == 0
and: ‘Email with receipt is sent to the customer’
email sent to customer
}
what we achieved?but we want more
file to maintain
IDE integration
direct link between steps and
implementation
fits all testing levels
can business work alone?
final thoughts
spock for BDD
spock for unit testing
.net frameworks
• specflow
• NSpec / StoryQ
• xbehave.net
• StoryTeller
BDD makes business and tech
people communicate better
communication is the key to
success
thank youtomek dubikowski
@tdubikowski
agilehabits.wordpress.com

More Related Content

Similar to Star Trek: BDD Enterprise

Антипаттерны модульного тестирования
Антипаттерны модульного тестированияАнтипаттерны модульного тестирования
Антипаттерны модульного тестирования
MitinPavel
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmers
elliando dias
 
Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
Nico Krijnen
 

Similar to Star Trek: BDD Enterprise (20)

Type safe embedded domain-specific languages
Type safe embedded domain-specific languagesType safe embedded domain-specific languages
Type safe embedded domain-specific languages
 
Антипаттерны модульного тестирования
Антипаттерны модульного тестированияАнтипаттерны модульного тестирования
Антипаттерны модульного тестирования
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSON
 
Finding the Right Testing Tool for the Job
Finding the Right Testing Tool for the JobFinding the Right Testing Tool for the Job
Finding the Right Testing Tool for the Job
 
Event Driven Architecture (Integration Tech Event 2019)
Event Driven Architecture (Integration Tech Event 2019)Event Driven Architecture (Integration Tech Event 2019)
Event Driven Architecture (Integration Tech Event 2019)
 
How to Send a Receipt, Topics in Concurrency and Distributed Systems
How to Send a Receipt, Topics in Concurrency and Distributed SystemsHow to Send a Receipt, Topics in Concurrency and Distributed Systems
How to Send a Receipt, Topics in Concurrency and Distributed Systems
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Ruby on Rails For Java Programmers
Ruby on Rails For Java ProgrammersRuby on Rails For Java Programmers
Ruby on Rails For Java Programmers
 
Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
 
Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016Modelling by Example Workshop - PHPNW 2016
Modelling by Example Workshop - PHPNW 2016
 
The case for consumer-driven contracts
The case for consumer-driven contractsThe case for consumer-driven contracts
The case for consumer-driven contracts
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
ConFoo 2024 - Need for Speed: Removing speed bumps in API Projects
ConFoo 2024  - Need for Speed: Removing speed bumps in API ProjectsConFoo 2024  - Need for Speed: Removing speed bumps in API Projects
ConFoo 2024 - Need for Speed: Removing speed bumps in API Projects
 
Week 7 html css js
Week 7   html css jsWeek 7   html css js
Week 7 html css js
 
MongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON SchemaMongoDB World 2019: Just-in-time Validation with JSON Schema
MongoDB World 2019: Just-in-time Validation with JSON Schema
 
Functional Web Development using Elm
Functional Web Development using ElmFunctional Web Development using Elm
Functional Web Development using Elm
 
Enabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projectsEnabling agile devliery through enabling BDD in PHP projects
Enabling agile devliery through enabling BDD in PHP projects
 
Nine Ways to Use Network-Side Scripting
Nine Ways to Use Network-Side ScriptingNine Ways to Use Network-Side Scripting
Nine Ways to Use Network-Side Scripting
 
Writing Go(od) Tests (FOSDEM 2020)
Writing Go(od) Tests (FOSDEM 2020)Writing Go(od) Tests (FOSDEM 2020)
Writing Go(od) Tests (FOSDEM 2020)
 
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
 

More from Stowarzyszenie Jakości Systemów Informatycznych (SJSI)

7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop
Stowarzyszenie Jakości Systemów Informatycznych (SJSI)
 
Dancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customerDancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customer
Stowarzyszenie Jakości Systemów Informatycznych (SJSI)
 
[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...
Stowarzyszenie Jakości Systemów Informatycznych (SJSI)
 
[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun
Stowarzyszenie Jakości Systemów Informatycznych (SJSI)
 

More from Stowarzyszenie Jakości Systemów Informatycznych (SJSI) (20)

Model based testing as a BA tool
Model based testing as a BA toolModel based testing as a BA tool
Model based testing as a BA tool
 
Communication - Language of Leader
Communication - Language of LeaderCommunication - Language of Leader
Communication - Language of Leader
 
Miękkie umiejętności w pracy analityka biznesu
Miękkie umiejętności w pracy analityka biznesuMiękkie umiejętności w pracy analityka biznesu
Miękkie umiejętności w pracy analityka biznesu
 
Błędy w analizie z praktyki (nowe wydanie  )
Błędy w analizie z praktyki (nowe wydanie  )Błędy w analizie z praktyki (nowe wydanie  )
Błędy w analizie z praktyki (nowe wydanie  )
 
7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop7 Skills for highly effective teams - workshop
7 Skills for highly effective teams - workshop
 
Dancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customerDancing with the devil - how to cooperate with a problematic customer
Dancing with the devil - how to cooperate with a problematic customer
 
Cosmic truths about software requirements
Cosmic truths about software requirementsCosmic truths about software requirements
Cosmic truths about software requirements
 
Zagraj w zaangażowanie
Zagraj w zaangażowanieZagraj w zaangażowanie
Zagraj w zaangażowanie
 
Analiza prawdziwie biznesowa - skąd biorą się projekty
Analiza prawdziwie biznesowa - skąd biorą się projektyAnaliza prawdziwie biznesowa - skąd biorą się projekty
Analiza prawdziwie biznesowa - skąd biorą się projekty
 
Internet of Things loves data - analysis of Industry 4.0
Internet of Things loves data - analysis of Industry 4.0Internet of Things loves data - analysis of Industry 4.0
Internet of Things loves data - analysis of Industry 4.0
 
Start with Accessibility: Why, How and What
Start with Accessibility: Why, How and WhatStart with Accessibility: Why, How and What
Start with Accessibility: Why, How and What
 
Agile business analyst
Agile business analystAgile business analyst
Agile business analyst
 
Analityk i architekt w czasach automatyzacji i robotyzacji biznesu
Analityk i architekt w czasach automatyzacji i robotyzacji biznesuAnalityk i architekt w czasach automatyzacji i robotyzacji biznesu
Analityk i architekt w czasach automatyzacji i robotyzacji biznesu
 
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BAJak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
Jak sprzedać swój pomysł w 5 minut, czyli pitch deck dla BA
 
7 Skills for highly effective teams
7 Skills for highly effective teams7 Skills for highly effective teams
7 Skills for highly effective teams
 
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
[TestWarez 2017] Skomplikowane testowanie, skomplikowane terminy. Testowanie ...
 
[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...[TestWarez 2017] Przychodzi tester na rozmowę...
[TestWarez 2017] Przychodzi tester na rozmowę...
 
[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun[TestWarez 2017] A proper gun makes testing fun
[TestWarez 2017] A proper gun makes testing fun
 
[TestWarez 2017] Zen testów wydajnościowych
[TestWarez 2017] Zen testów wydajnościowych[TestWarez 2017] Zen testów wydajnościowych
[TestWarez 2017] Zen testów wydajnościowych
 
[TestWarez 2017] „Przypadek Testowy” a „Kliencki Przypadek Użycia”
[TestWarez 2017] „Przypadek Testowy” a „Kliencki Przypadek Użycia”[TestWarez 2017] „Przypadek Testowy” a „Kliencki Przypadek Użycia”
[TestWarez 2017] „Przypadek Testowy” a „Kliencki Przypadek Użycia”
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 

Star Trek: BDD Enterprise

  • 2. let’s have a small trip around the universe
  • 3. every ship needs 
 a captain
  • 4.
  • 9.
  • 13. documentation is the main source of knowledge CR - 271 CR - 228 CR - 419 CR - 56 CR - 94 CR - 382 CR - 253 CR - 212 CR - 199 CR - 158
  • 14.
  • 15. what if I told you that you can know how the system works based on how it actually works?
  • 17. working software over comprehensive documentation
  • 18.
  • 19. test scenario describes system behavior green test means that system actually behaves as described red test means that system doesn’t behave as described
  • 20.
  • 24. behavior driven development think how your system should behave create test scenario for the behavior development team implements the behavior ok, genius wait a minute given – when – then
  • 25. not sure if BDD
  • 26. is not just TDD
  • 27. @Test public void shouldDoSomethingWhenSomething() { // given ... // when ... // then ... } my unit tests are like that
  • 28. BDD is like TDD if…
  • 29.
  • 30. BDD TDD test first unit testing • analysis • design • code / test • code / test
  • 31. think how your system should behave create test scenario for the behavior development team implements the behavior i do the same stuff in excel
  • 32. where is the difference
  • 33. where is the difference
  • 34. aww, but this is technical stuff
  • 35. aww, but this is technical stuff unit integration system
  • 37. Narrative: As account user I want to make money transfer on my account Scenario: Outgoing transfer from user account Given: User has 100$ on his account When: User makes a 50$ transfer to another account Then: User has 50$ on his account And: Another account state has increased by 50$ a little twist story file
  • 38. reports = current documentation green systems behaves like described in scenario
  • 39. use the right tools
  • 40. story file code file how (most of) these work implements
  • 41. two files to maintain high coupling
  • 42. @Then("the value returned is empty") public void theValueIsEmpty() { ... } @Then("the value returned is $value") public void theValueIs(String value) { ... } the actual code regex matching jre dependent
  • 44. heavyweight players only for system test level
  • 45. hello again, captain spock use spock, it’s better
  • 46.
  • 47. groovy is groovy because: • dynamic language • functional style • easy for java developers • syntax boosts • syntax simplifications
  • 48. powerful for DSLs even spock’s syntax is DSL
  • 49. business use case Narrative: Customers do the shopping in our shop. When he checks out we need to calculate the right delivery charge depending on the total value of the basket, delivery date and if customer has bought delivery subscription. Scenario: Shopping for more than 40£ should not be charged Given: Customer has products for 50£ in the basket When: Customer checks out Then: No delivery charge is added to the receipt And: Email with receipt is sent to the customer let’s migrate it to spock
  • 50. Narrative: Customers do the shopping in our shop. When he checks out we need to calculate the right delivery charge depending on the total value of the basket, delivery date and if customer has bought delivery subscription. @Narrative(‘’’ Customers do the shopping in our shop. When he checks out we need to calculate the right delivery charge depending on the total value of the basket, delivery date and if customer has bought delivery subscription. ‘’’) @Title(‘Delivery charge specification’) @Narrative(‘’’ Customers do the shopping in our shop. When he checks out we need to calculate the right delivery charge depending on the total value of the basket, delivery date and if customer has bought delivery subscription. ‘’’) class DeliveryChargeTest extends Specification { first things first – narrative not that technical
  • 51. Scenario: Shopping for more than 40£ should not be charged Given: Customer has products for 50£ in the basket When: Customer checks out Then: No delivery charge is added to the receipt And: Email with receipt is sent to the customer second step – scenario def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ when: ‘Customer checks out’ then: ‘No delivery charge is added to the receipt’ and: ‘Email with receipt is sent to the customer’ } def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ <code> when: ‘Customer checks out’ <code> then: ‘No delivery charge is added to the receipt’ <code> and: ‘Email with receipt is sent to the customer’ <code> }
  • 52.
  • 53. def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ Customer customer = aCustomer.withBasket(aBasket.with(...)).build(); when: ‘Customer checks out’ Order order = customer.checkOut(new Date()); then: ‘No delivery charge is added to the receipt’ assertThat(order.getDeliveryCharge()).isEqualTo(0); and: ‘Email with receipt is sent to the customer’ verify(emailService).sendMessage(customer.getEmailAddres(), anyMessage()) } give me a try, please def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ Customer customer = aCustomerWith50PoundsWorthBakset(); when: ‘Customer checks out’ Order order = chechout(customer); then: ‘No delivery charge is added to the receipt’ assertThatDeliveryChargeIsZero(order); and: ‘Email with receipt is sent to the customer’ verifyThatEmailWasSentTo(customer); } def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ def customer = ‘a customer with 50£ worth basket’() when: ‘Customer checks out’ def order = checkout customer then: ‘No delivery charge is added to the receipt’ ‘delivery charge of’ order == 0 and: ‘Email with receipt is sent to the customer’ ‘email was sent to’ customer } def ‘Shopping for more than 40£ should not be charged’ () { given: ‘Customer has products for 50£ in the basket’ customer with basket of value 50 when: ‘Customer checks out’ customer checkouts order then: ‘No delivery charge is added to the receipt’ delivery charge == 0 and: ‘Email with receipt is sent to the customer’ email sent to customer }
  • 54. what we achieved?but we want more
  • 56. IDE integration direct link between steps and implementation
  • 59.
  • 61. spock for BDD spock for unit testing
  • 62. .net frameworks • specflow • NSpec / StoryQ • xbehave.net • StoryTeller
  • 63. BDD makes business and tech people communicate better
  • 64. communication is the key to success