SlideShare a Scribd company logo
1 of 34
Download to read offline
BDD REVOLUTION
OR HOW WE CAME BACK FROM HELL
@mpzalewski
https://github.com/Zales0123
MATEUSZ ZALEWSKI
@mpzalewski
Zales0123
mpzalewski.com
2
3
BDD is a process designed to aid the management and the delivery of software
development projects by improving communication between engineers and
business professionals.
BEHAVIOUR DRIVEN
DEVELOPMENT
BDD is a process designed to aid the management and the delivery of software
development projects by improving communication between engineers and
business professionals.
http://inviqa.com/insights/bdd-guide
4
5
Given "PHP T-Shirt" is priced at €100.00
And the store has "VAT" tax rate of 23%
When I add product "PHP T-Shirt" to the cart
Then my cart taxes should be €23.00
6
/**
* @Given :product is priced at :price
*/
public function productIsPricedAt(ProductInterface $product, int $price): void
{
$product->setPrice($price);
}
/**
* @Then /^(my cart) taxes should be ("[^"]+")$/
*/
public function myCartTaxesShouldBe(CartInterface $cart, int $money): void
{
Assert::eq($cart->getTaxesTotal(), $money);
}
7
LESS AMBIGUITY
=
LESS MISUNDERSTANDINGS
8
9
10
11
12
13
14
15
https://www.theverge.com/2016/5/5/11592622/this-is-fine-meme-comic
16
17
18
19
20
21
GHERKIN STEP
PHP CODE
CONTEXT
22
/**
* @When I choose :countryName
*/
public function iChoose(string $countryName): void
{
$this->createPage->chooseName($countryName);
}
/**
* @When I save my changes
* @When I try to save changes
*/
public function iSaveMyChanges(): void
{
$this->updatePage->saveChanges();
}
/**
* @Then I should not be able to choose :name
*/
public function iShouldNotBeAbleToChoose(string $name): void
{
try {
$this->createPage->chooseName($name);
} catch (ElementNotFoundException $exception) {
return;
}
throw new Exception(sprintf('I should not be able to choose "%s".', $name));
}
23
VALUE
OBJECT
TRANSFORM
ER
24
/**
* @Transform /^coupon "([^"]+)"$/
* @Transform /^"([^"]+)" coupon$/
* @Transform :coupon
*/
public function getCouponByCode(string $couponCode): CouponInterface
{
$coupon = $this->couponRepository->findOneBy(['code' => $couponCode]);
Assert::notNull(
$coupon,
sprintf('Coupon with code "%s" does not exist', $couponCode)
);
return $coupon;
}
25
/**
* @var SharedStorageInterface
*/
private $sharedStorage;
public function __construct(SharedStorageInterface $sharedStorage)
{
$this->sharedStorage = $sharedStorage;
}
/**
* @Transform /^(it|its|theirs|them)$/
*/
public function getLatestResource()
{
return $this->sharedStorage->getLatestResource();
}
/**
* @Transform /^(?:this|that|the) ([^"]+)$/
*/
public function getResource($resource)
{
return $this->sharedStorage->get(StringInflector::nameToCode($resource));
}
26
When I add this product to the cart
When I browse that channel
Then this item should have name "T-shirt banana"
27
PHP CODE
API
PAGE
UI CLI
28
class SummaryPage extends SymfonyPage implements SummaryPageInterface
{
public function getRouteName(): string
{
return 'sylius_shop_cart_summary';
}
public function getGrandTotal(): string
{
$totalElement = $this->getElement('grand_total');
return $totalElement->getText();
}
public function removeProduct(string $productName): void
{
$itemElement = $this
->getElement('product_row', ['%name%' => $productName])
;
$itemElement
->find('css', ‚button.sylius-cart-remove-button')
->press()
;
}
}
29
FRIENDS OF BEHAT
30
!
31
BUSINESS VALUE
CODE VALUE
32
Have no fear of perfection - you’ll never reach it.
~ Salvador Dali
33
THANK YOU
@mpzalewskihttps://github.com/Zales0123

More Related Content

Similar to BDD Revolution - or how we came back from hell

Confoo 2023 - Business logic testing with Behat, Twig and Api Platform
Confoo 2023 - Business logic testing with Behat, Twig and Api PlatformConfoo 2023 - Business logic testing with Behat, Twig and Api Platform
Confoo 2023 - Business logic testing with Behat, Twig and Api PlatformMateusz Zalewski
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your CodeAbbas Ali
 
[PHPers Summit 2023] Business logic testing
[PHPers Summit 2023] Business logic testing[PHPers Summit 2023] Business logic testing
[PHPers Summit 2023] Business logic testingMateusz Zalewski
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentspsstoev
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWordCamp Indonesia
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2Paras Mendiratta
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design PatternsBobby Bouwmann
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++varun arora
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using CodeceptionJeroen van Dijk
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Fabio Biondi
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Python Ireland
 
Symfony World - Symfony components and design patterns
Symfony World - Symfony components and design patternsSymfony World - Symfony components and design patterns
Symfony World - Symfony components and design patternsŁukasz Chruściel
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created itPaul Bearne
 

Similar to BDD Revolution - or how we came back from hell (20)

JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Confoo 2023 - Business logic testing with Behat, Twig and Api Platform
Confoo 2023 - Business logic testing with Behat, Twig and Api PlatformConfoo 2023 - Business logic testing with Behat, Twig and Api Platform
Confoo 2023 - Business logic testing with Behat, Twig and Api Platform
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
 
Borrador del blog
Borrador del blogBorrador del blog
Borrador del blog
 
[PHPers Summit 2023] Business logic testing
[PHPers Summit 2023] Business logic testing[PHPers Summit 2023] Business logic testing
[PHPers Summit 2023] Business logic testing
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
 
WooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda BagusWooCommerce CRUD and Data Store by Akeda Bagus
WooCommerce CRUD and Data Store by Akeda Bagus
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design Patterns
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++
 
Refactoring using Codeception
Refactoring using CodeceptionRefactoring using Codeception
Refactoring using Codeception
 
Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)Single Page Applications in Angular (italiano)
Single Page Applications in Angular (italiano)
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 
Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)Google App Engine in 40 minutes (the absolute essentials)
Google App Engine in 40 minutes (the absolute essentials)
 
Symfony World - Symfony components and design patterns
Symfony World - Symfony components and design patternsSymfony World - Symfony components and design patterns
Symfony World - Symfony components and design patterns
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
 

Recently uploaded

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

BDD Revolution - or how we came back from hell

  • 1. BDD REVOLUTION OR HOW WE CAME BACK FROM HELL @mpzalewski https://github.com/Zales0123 MATEUSZ ZALEWSKI
  • 3. 3
  • 4. BDD is a process designed to aid the management and the delivery of software development projects by improving communication between engineers and business professionals. BEHAVIOUR DRIVEN DEVELOPMENT BDD is a process designed to aid the management and the delivery of software development projects by improving communication between engineers and business professionals. http://inviqa.com/insights/bdd-guide 4
  • 5. 5
  • 6. Given "PHP T-Shirt" is priced at €100.00 And the store has "VAT" tax rate of 23% When I add product "PHP T-Shirt" to the cart Then my cart taxes should be €23.00 6
  • 7. /** * @Given :product is priced at :price */ public function productIsPricedAt(ProductInterface $product, int $price): void { $product->setPrice($price); } /** * @Then /^(my cart) taxes should be ("[^"]+")$/ */ public function myCartTaxesShouldBe(CartInterface $cart, int $money): void { Assert::eq($cart->getTaxesTotal(), $money); } 7
  • 9. 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 23. /** * @When I choose :countryName */ public function iChoose(string $countryName): void { $this->createPage->chooseName($countryName); } /** * @When I save my changes * @When I try to save changes */ public function iSaveMyChanges(): void { $this->updatePage->saveChanges(); } /** * @Then I should not be able to choose :name */ public function iShouldNotBeAbleToChoose(string $name): void { try { $this->createPage->chooseName($name); } catch (ElementNotFoundException $exception) { return; } throw new Exception(sprintf('I should not be able to choose "%s".', $name)); } 23
  • 25. /** * @Transform /^coupon "([^"]+)"$/ * @Transform /^"([^"]+)" coupon$/ * @Transform :coupon */ public function getCouponByCode(string $couponCode): CouponInterface { $coupon = $this->couponRepository->findOneBy(['code' => $couponCode]); Assert::notNull( $coupon, sprintf('Coupon with code "%s" does not exist', $couponCode) ); return $coupon; } 25
  • 26. /** * @var SharedStorageInterface */ private $sharedStorage; public function __construct(SharedStorageInterface $sharedStorage) { $this->sharedStorage = $sharedStorage; } /** * @Transform /^(it|its|theirs|them)$/ */ public function getLatestResource() { return $this->sharedStorage->getLatestResource(); } /** * @Transform /^(?:this|that|the) ([^"]+)$/ */ public function getResource($resource) { return $this->sharedStorage->get(StringInflector::nameToCode($resource)); } 26
  • 27. When I add this product to the cart When I browse that channel Then this item should have name "T-shirt banana" 27
  • 29. class SummaryPage extends SymfonyPage implements SummaryPageInterface { public function getRouteName(): string { return 'sylius_shop_cart_summary'; } public function getGrandTotal(): string { $totalElement = $this->getElement('grand_total'); return $totalElement->getText(); } public function removeProduct(string $productName): void { $itemElement = $this ->getElement('product_row', ['%name%' => $productName]) ; $itemElement ->find('css', ‚button.sylius-cart-remove-button') ->press() ; } } 29
  • 31. ! 31
  • 33. Have no fear of perfection - you’ll never reach it. ~ Salvador Dali 33