Full stack BDD for Symfony2

10,528 views

Published on

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.

Published in: Technology

Full stack BDD for Symfony2

  1. 1. Full Stack BDD for Symfony2 Marcello Duarte Konstantin Kudryashov
  2. 2. About usMarcello DuarteHead of TrainingKonstantin KudryashovLead Developer
  3. 3. This talk • Where are we coming from • Why BDD • Behat Best Practices • Introducing a new tool
  4. 4. from Cucumber to
  5. 5. Adults don’t thinktheir way into a new way of acting
  6. 6. Adults don’t thinktheir way into a new way of acting They act their way into a new way of thinking
  7. 7. Ask Why
  8. 8. from xUnit to xSpec HP S pec P
  9. 9. ? ? ?? ? ? ? ? Test ? ? ? ? ?? ? ? ? ?
  10. 10. code coverage private xUnitdatabase mocking assert structure
  11. 11. Language matter
  12. 12. 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);
  13. 13. Tools matter
  14. 14. Why BDD?
  15. 15. Requirements Analysis Design Develop Test 9 months 3 months 2 months 12 months ...[Royce 1970]
  16. 16. Most of the cost insoftware development is in feedback delay
  17. 17. Requirements Acceptance Test Code Refactoring ~20 minutes[Beck & Cunningham 1996-99]
  18. 18. Let’s reducefeedback delay
  19. 19. Let’s rename a few things
  20. 20. Narratives (Why?) Examples (What do you mean?) Describe Object How! Implement Incremental Design[North 03]
  21. 21. Building a simpleStudent can enrol on a course feature
  22. 22. You can follow our stepshttp://git.io/t4kQ5Q
  23. 23. 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!
  24. 24. Behat tips• Favour MinkAwareInterface over MinkContext• Extract context per role• Group features under feature folder• Use Mink API• Integrate with framework at config level
  25. 25. PHPSpec2 tips• Describe classes not configuration• Concentrate on messages/behaviours
  26. 26. ? ? ?? ? ? ? ?Questions ? ? ? ? ?? ? ? ? ?
  27. 27. joind.in/7064 Thanks! :)

×