Behavior driven development

966 views
896 views

Published on

Behavior-Driven Development in PHP with Behat BDD framework

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
966
On SlideShare
0
From Embeds
0
Number of Embeds
37
Actions
Shares
0
Downloads
23
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • No extra code, not needed\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • http://dannorth.net/whats-in-a-story/\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • extension to TDD\nNatural language=more dynamic syntax (e.g. plural)\n\n
  • Syntax: I -> We, Uppercase, Tense, ...\nTest scope: API, GUI, Backend only, ...\nEnvironment: DB restore strategies, ...\nToo complicated = tests have to be tested\n
  • \n
  • \n
  • Behavior driven development

    1. 1. BDD Behavior Driven Development in PHP Slide 1TEQneers GmbH & Co. KG www.teqneers.de
    2. 2. Development: back then and today Slide 2TEQneers GmbH & Co. KG www.teqneers.de
    3. 3. Dirty Hacking Slide 3TEQneers GmbH & Co. KG www.teqneers.de
    4. 4. Dirty Hacking ‣ No documentation ‣ No testing ‣ No clue if it still working ‣ Maintenance doesn’t really matter ‣ Code changes are a lottery ‣ Easy refactoring impossible Slide 4TEQneers GmbH & Co. KG www.teqneers.de
    5. 5. Automated testing Slide 5TEQneers GmbH & Co. KG www.teqneers.de
    6. 6. Automated Testing ✓Verify code or results ✓Can be automated ✓Code first, add tests later ‣ Time gap between development and testing ‣ Test not based on original requirements ‣ Tests influenced by code Slide 6TEQneers GmbH & Co. KG www.teqneers.de
    7. 7. Test-Driven Development Slide 7TEQneers GmbH & Co. KG www.teqneers.de
    8. 8. Test-Driven Development ✓Tests follow your original requirements ✓Code is an easy solution to the problem ✓Tests for all code Slide 8TEQneers GmbH & Co. KG www.teqneers.de
    9. 9. Test-Driven Development ‣ Write tests first, add code later ‣ Feels unnatural ‣ Tests written by developers ‣ Potential for over-design ‣ Customer unable to participate Slide 9TEQneers GmbH & Co. KG www.teqneers.de
    10. 10. Behavior-Driven Development Slide 10TEQneers GmbH & Co. KG www.teqneers.de
    11. 11. Audience Customer Slide 11TEQneers GmbH & Co. KG www.teqneers.de
    12. 12. Audience Customer Tester Slide 11TEQneers GmbH & Co. KG www.teqneers.de
    13. 13. Audience Customer Developer Tester Slide 11TEQneers GmbH & Co. KG www.teqneers.de
    14. 14. In order to finish a purchase we need to add VAT to the total. Customer Developer Tester Slide 12TEQneers GmbH & Co. KG www.teqneers.de
    15. 15. <?php foreach( $itemList as $item) { $total += $item[price] * $item[quantity]; } $total = $sum * 1.19; ?> Customer Developer Tester Slide 13TEQneers GmbH & Co. KG www.teqneers.de
    16. 16. Take all items add them up multiply by VAT total should be sum + VAT Customer Developer Tester Slide 14TEQneers GmbH & Co. KG www.teqneers.de
    17. 17. Translation Slide 15TEQneers GmbH & Co. KG www.teqneers.de
    18. 18. Translation Slide 16TEQneers GmbH & Co. KG www.teqneers.de
    19. 19. Goal ‣ Common language ‣ Tester writing tests ‣ Customer writing specs ‣ Common dictionary ‣ Specs == Tests Slide 17TEQneers GmbH & Co. KG www.teqneers.de
    20. 20. Behavior-Driven Development ‣ Writing tests first in a customer friendly language ‣ Your tests are your specifications and your specifications are your tests ‣ Dan North: “BDD takes the position that you can turn an idea for a requirement into implemented, tested, production-ready code simply and effectively, as long as the requirement is specific enough that everyone knows what’s going on.” Slide 18TEQneers GmbH & Co. KG www.teqneers.de
    21. 21. Gherkin ‣ Feature: Generating an invoice ‣ Scenario: Calculating gross total in Germany ‣ Given the customer is from Germany ‣ And the net total is 100 EUR ‣ When I calculate the gross total ‣ Then the final invoice total should be 119 EUR Slide 19TEQneers GmbH & Co. KG www.teqneers.de
    22. 22. Gherkin Compatible BDD Frameworks ‣ Ruby: Cucumber ‣ Java: Cucumber-JVM ‣ .NET: IronRuby ‣ Erlangen: cucumberl ‣ PHP: Behat Slide 20TEQneers GmbH & Co. KG www.teqneers.de
    23. 23. Behat ‣ Extendable PHP BDD Framework ‣ Mink: browser testing (e.g. Selenium) ‣ Symfony2: integration layer ‣ Jira: bug tracker interface ‣ Gearman: distributed testing ‣ ... Slide 21TEQneers GmbH & Co. KG www.teqneers.de
    24. 24. What’s testable in Behat? ‣ Business Intelligence/Models ‣ API’s ‣ Web Pages ‣ Single Scripts ‣ Server-Server-Interaction Slide 22TEQneers GmbH & Co. KG www.teqneers.de
    25. 25. How does it work? Slide 23TEQneers GmbH & Co. KG www.teqneers.de
    26. 26. What BDD is NOT ‣ No replacement for TDD ‣ Not a “real” spoken language ‣ Not a drop in solution ‣ Common language needs to be developed ‣ Developer still has to write glue code ‣ It’s not magic! Slide 24TEQneers GmbH & Co. KG www.teqneers.de
    27. 27. Good Practice ‣ Get everyone on board ‣ Define common language and syntax ‣ Define test scope ‣ Build project specific testing environment ‣ Don’t expect perfect solution from start ‣ Don’t make it too complicated Slide 25TEQneers GmbH & Co. KG www.teqneers.de
    28. 28. Questions? Slide 26TEQneers GmbH & Co. KG www.teqneers.de
    29. 29. Thanks for listening contact us if you have any questions email: oliver@php.net email: stefan@teqneers.de Have Fun! Slide 27TEQneers GmbH & Co. KG www.teqneers.de

    ×