SlideShare a Scribd company logo
1 of 29
Download to read offline
Full Stack BDD for
  Symfony2

  Marcello Duarte
  Konstantin Kudryashov
About us

Marcello Duarte
Head of Training




Konstantin Kudryashov
Lead Developer
This talk



  • Where are we coming from
  • Why BDD
  • Behat Best Practices
  • Introducing a new tool
from
  Cucumber to
Adults don’t think
their way into a new
   way of acting
Adults don’t think
their way into a new
   way of acting




 They act their way
 into a new way of
      thinking
Ask Why
from xUnit
       to xSpec



    HP S pec
  P
?   ?   ?
?        ?
      ?      ?
   ? Test        ?
  ? ?        ?
        ?
?    ? ?   ?   ?
code coverage
 private

            xUnit
database            mocking

   assert
              structure
Language matter
public function testUpdateWithEqualTypes()
{
    $installer = $this->createInstallerMock();
    $manager   = new InstallationManager('vendor');
    $manager->addInstaller($installer);

    $initial   = $this->createPackageMock();
    $target    = $this->createPackageMock();
    $operation = new UpdateOperation($initial, $target, 'test');

    $initial
        ->expects($this->once())
        ->method('getType')
        ->will($this->returnValue('library'));
    $target
        ->expects($this->once())
        ->method('getType')
        ->will($this->returnValue('library'));

    $installer
        ->expects($this->once())
        ->method('supports')
        ->with('library')
        ->will($this->returnValue(true));

    $installer
        ->expects($this->once())
        ->method('update')
        ->with($this->repository, $initial, $target);
Tools matter
Why BDD?
Requirements



                                  Analysis




                                             Design




                                                      Develop




                                                                Test




               9 months         3 months 2 months 12 months      ...


[Royce 1970]
Most of the cost in
software development
        is in
 feedback delay
Requirements




                                Acceptance

                                                      Test




                                                                 Code



                                             Refactoring




                                                   ~20 minutes



[Beck & Cunningham 1996-99]
Let’s reduce
feedback delay
Let’s rename a
  few things
Narratives
              (Why?)


                           Examples
                          (What do you
                            mean?)
                                               Describe
                                                Object



                                                  How!    Implement


                                         Incremental
                                            Design




[North 03]
Building a simple
Student can enrol
   on a course
       feature
You can follow
  our steps
http://git.io/t4kQ5Q
BDD Rules

• No examples until you have a red step
• No code until you have a red example
• No more code than enough to make it green
• Don’t get carried away!
Behat tips

• Favour MinkAwareInterface over MinkContext
• Extract context per role
• Group features under feature folder
• Use Mink API
• Integrate with framework at config level
PHPSpec2 tips

• Describe classes not configuration
• Concentrate on messages/behaviours
?   ?     ?
?         ?
        ?         ?
   ?Questions ?
  ? ?        ?
       ?
?    ? ?   ?   ?
joind.in/7064

  Thanks! :)

More Related Content

More from Marcello Duarte

More from Marcello Duarte (15)

Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
Empathy from Agility
Empathy from AgilityEmpathy from Agility
Empathy from Agility
 
Introducing Eager Design
Introducing Eager DesignIntroducing Eager Design
Introducing Eager Design
 
Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015Understanding Craftsmanship SwanseaCon2015
Understanding Craftsmanship SwanseaCon2015
 
Transitioning to Agile
Transitioning to AgileTransitioning to Agile
Transitioning to Agile
 
Understanding craftsmanship
Understanding craftsmanshipUnderstanding craftsmanship
Understanding craftsmanship
 
Hexagonal symfony
Hexagonal symfonyHexagonal symfony
Hexagonal symfony
 
The framework as an implementation detail
The framework as an implementation detailThe framework as an implementation detail
The framework as an implementation detail
 
PhpSpec 2.0 ilustrated by examples
PhpSpec 2.0 ilustrated by examplesPhpSpec 2.0 ilustrated by examples
PhpSpec 2.0 ilustrated by examples
 
Emergent design with phpspec
Emergent design with phpspecEmergent design with phpspec
Emergent design with phpspec
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
 
Deliberate practice
Deliberate practiceDeliberate practice
Deliberate practice
 
BDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpecBDD For Zend Framework With PHPSpec
BDD For Zend Framework With PHPSpec
 
PHPSpec BDD for PHP
PHPSpec BDD for PHPPHPSpec BDD for PHP
PHPSpec BDD for PHP
 
PHPSpec BDD Framework
PHPSpec BDD FrameworkPHPSpec BDD Framework
PHPSpec BDD Framework
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Full stack BDD for Symfony2

  • 1. Full Stack BDD for Symfony2 Marcello Duarte Konstantin Kudryashov
  • 2. About us Marcello Duarte Head of Training Konstantin Kudryashov Lead Developer
  • 3. This talk • Where are we coming from • Why BDD • Behat Best Practices • Introducing a new tool
  • 5.
  • 6. Adults don’t think their way into a new way of acting
  • 7. Adults don’t think their way into a new way of acting They act their way into a new way of thinking
  • 9. from xUnit to xSpec HP S pec P
  • 10. ? ? ? ? ? ? ? ? Test ? ? ? ? ? ? ? ? ? ?
  • 11. code coverage private xUnit database mocking assert structure
  • 13. public function testUpdateWithEqualTypes() { $installer = $this->createInstallerMock(); $manager = new InstallationManager('vendor'); $manager->addInstaller($installer); $initial = $this->createPackageMock(); $target = $this->createPackageMock(); $operation = new UpdateOperation($initial, $target, 'test'); $initial ->expects($this->once()) ->method('getType') ->will($this->returnValue('library')); $target ->expects($this->once()) ->method('getType') ->will($this->returnValue('library')); $installer ->expects($this->once()) ->method('supports') ->with('library') ->will($this->returnValue(true)); $installer ->expects($this->once()) ->method('update') ->with($this->repository, $initial, $target);
  • 16. Requirements Analysis Design Develop Test 9 months 3 months 2 months 12 months ... [Royce 1970]
  • 17. Most of the cost in software development is in feedback delay
  • 18. Requirements Acceptance Test Code Refactoring ~20 minutes [Beck & Cunningham 1996-99]
  • 20. Let’s rename a few things
  • 21. Narratives (Why?) Examples (What do you mean?) Describe Object How! Implement Incremental Design [North 03]
  • 22.
  • 23. Building a simple Student can enrol on a course feature
  • 24. You can follow our steps http://git.io/t4kQ5Q
  • 25. BDD Rules • No examples until you have a red step • No code until you have a red example • No more code than enough to make it green • Don’t get carried away!
  • 26. Behat tips • Favour MinkAwareInterface over MinkContext • Extract context per role • Group features under feature folder • Use Mink API • Integrate with framework at config level
  • 27. PHPSpec2 tips • Describe classes not configuration • Concentrate on messages/behaviours
  • 28. ? ? ? ? ? ? ? ?Questions ? ? ? ? ? ? ? ? ? ?