BDD with Behat
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

BDD with Behat

  • 5,977 views
Uploaded on

A talk I gave at pdxphp about using Behat for Behavior Driven Development

A talk I gave at pdxphp about using Behat for Behavior Driven Development

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
5,977
On Slideshare
5,974
From Embeds
3
Number of Embeds
3

Actions

Shares
Downloads
88
Comments
3
Likes
14

Embeds 3

http://paper.li 1
http://www.docshut.com 1
http://symfony2developer.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. BDD with Behat
  • 2. Who am I? Richard D Shank [email_address] @IamPersistent Freelancer Symfony2 developer Wanna be rock star
  • 3. What is BDD? Behavior Driven Development
  • 4. What is BDD? What does that mean?
  • 5. Testing We know we should do it, why don't we?
    • It takes too much time
    • 6. It slows me down
    • 7. The boss won't let me
    • 8. I'm not really sure how
  • 9. Testing
    • Write code
    • 10. Write tests
    • The test is written to match code
    • 11. It carries the bias of our code
    • 12. Its just too much trouble
  • 13. TDD Solution: Test Driven Development
  • 14. TDD Test written before code
    • Eliminates bias
    • 15. You know the test will be written
  • 16. TDD What the hell do I test?
  • 17. BDD Behavior Driven Development
  • 18. BDD What makes it different? Its written from the outside in, driven by the business value
  • 19. BDD How does it work? You tell a story When a customer clicks on a blue widget, it is added to their shopping cart.
  • 20. BDD Advantages
    • Clarifies up front what needs to be done
    • 21. It is written in everyday, spoken language
    • 22. Anyone can understand and write stories
    • 23. Makes everyone think about the requirements
    • 24. It keeps you focused on what is necessary - YAGNI
  • 25. Gherkin
  • 26. Behat
    • System to write and test stories
    • 27. Uses Gherkin syntax
    • 28. 6 step process
    • 29. PHP 5.3
  • 30. Installation $ pear channel-discover pear.everzet.com $ pear install everzet/behat-beta
  • 31. File organization
  • 32. Step 1 - Behavior addition.feature
  • 33. Step 2 – Object Definition Steps are generated Calculator.php
  • 34. Step 2 – Object Definition *Writing a stub class is not really the BDD way of doing things, PHP doesn't handle 'method not found' exceptions very well, so the stub class is necessary for PHP
  • 35. Step 2 – Generate Steps
  • 36. Step 2 – Step Definition steps/calculator.php
  • 37. Step 2 – Add support support/env.php
  • 38. Step 3 - Write a definition
  • 39. Step 4 – Run it, watch it fail
  • 40. Step 5 – Write the code
  • 41. Step 6 – Run it, watch it pass!
  • 42. Wash, rinse, repeat Keep repeating the process until all tests pass.
  • 43. Write step for add
  • 44. Watch it fail
  • 45. Write the code
  • 46. Watch it pass
  • 47. Write step for result
  • 48. Watch it fail
  • 49. Write the code
  • 50. Watch it pass
  • 51. Unit Testing Does not replace unit testing, It supplements it
  • 52. More complex
  • 53. Scenario Outlines
  • 54. Backgrounds
  • 55. Hooks
  • 56. In-step calls
  • 57. New feature
  • 58. Learn more http://en.wikipedia.org/wiki/Behavior_Driven_Development http://blog.dannorth.net/introducing-bdd https://github.com/aslakhellesoy/cucumber/wiki http://cukes.info http://everzet.com/Behat https://github.com/everzet/Behat http://www.pragprog.com/titles/achbd/the-rspec-book http://scotland-on-rails.s3.amazonaws.com/1A06_JosephWilk-SOR.mp4