Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Full stack BDD for Symfony2

Full stack BDD for Symfony2

Many Symfony2 developers have heard about Behat and even use it regularly in their Symfony projects. If you have found value in this tool and the BDD practices it was inspired on, come join us for this talk as we will expand on what other benefits these practices and other BDD tools available can bring. This very illustrative talk will not only present you with the tools but show how to use them together to build beautifully architected, business-oriented Symfony2 applications.

https://joind.in/7064
https://github.com/everzet/fullstack-bdd-sflive2012/commits/master

Konstantin Kudryashov

September 14, 2012
Tweet

More Decks by Konstantin Kudryashov

Other Decks in Programming

Transcript

  1. Full Stack BDD for Symfony2 Marcello Duarte Konstantin Kudryashov

  2. Marcello Duarte Head of Training Konstantin Kudryashov Lead Developer About

    us
  3. • Where are we coming from • Why BDD •

    Behat Best Practices • Introducing a new tool This talk
  4. from Cucumber to

  5. None
  6. Adults don’t think their way into a new way of

    acting
  7. They act their way into a new way of thinking

    Adults don’t think their way into a new way of acting
  8. Ask Why

  9. PHPSpec from xUnit to xSpec

  10. Test ? ? ? ? ? ? ? ? ?

    ? ? ? ? ? ? ? ? ?
  11. xUnit assert code coverage structure private database mocking

  12. Language matter

  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);
  14. Tools matter

  15. Why BDD?

  16. [Royce 1970] Requirements Analysis Design Develop Test 9 months 3

    months 2 months 12 months ...
  17. Most of the cost in software development is in feedback

    delay
  18. Refactoring Code Test Requirements Acceptance ~20 minutes [Beck & Cunningham

    1996-99]
  19. Let’s reduce feedback delay

  20. Let’s rename a few things

  21. Incremental Design Implement Describe Object Narratives (Why?) Examples (What do

    you mean?) How! [North 03]
  22. None
  23. Building a simple Student can enrol on a course feature

  24. You can follow our steps http://git.io/t4kQ5Q

  25. • 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! BDD Rules
  26. • Favour MinkAwareInterface over MinkContext • Extract context per role

    • Group features under feature folder • Use Mink API • Integrate with framework at config level Behat tips
  27. • Describe classes not configuration • Concentrate on messages/behaviours PHPSpec2

    tips
  28. Questions ? ? ? ? ? ? ? ? ?

    ? ? ? ? ? ? ? ? ?
  29. joind.in/7064 Thanks! :)