Your SlideShare is downloading. ×
0
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)

3,222

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,222
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
2
Embeds 0
No embeds

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. TDD in PHP: A Brief Example
  • 2. About Me Jeremy Kendall PHP Developer since 2001 Organizer Memphis PHP Contributor to FRAPI project (getfrapi.com) [email_address] @JeremyKendall http://jeremykendall.net
  • 3. TDD in PHP: A Brief Example Test Driven Development, you say?
  • 4. Frankly, my dear . . .
  • 5. Why You Should Give A Damn <ul>Test Driven Development is perhaps one of the best and fastest ways to improve your understanding and command of object-oriented principles and best practices. ” Good design is testable, and design that isn't testable is bad.” - Michael C. Feathers </ul>
  • 6. What is TDD? <ul><li>From Wikipedia:
  • 7. ” Test Driven Development (TDD) is a software development process that relies on the repetition of a very short development cycle . . .” </li></ul>
  • 8. TDD Development Process <ul><li>Write a test
  • 9. Run all tests, watch new test fail
  • 10. Write just enough code to make the test pass
  • 11. Run all tests, watch new test pass
  • 12. Lather, rinse, repeat . . .
  • 13. Refactor </li></ul>
  • 14. TDD: The Benefits <ul><li>High cohesion, loose coupling
  • 15. Confidence
  • 16. Faster time to resolution
  • 17. Documentation </li></ul>
  • 18. TDD: The Drawbacks <ul><li>Tests only cover what you think should be tested
  • 19. False sense of confidence
  • 20. Without management and team buy-in, TDD is DOA </li></ul>
  • 21. TDD: Live Code Example <ul>Live Coding? Really? Why? </ul>
  • 22. TDD: Live Code Example <ul><li>Goals </li><ul><li>Practical example of TDD in action
  • 23. Demonstrate refactoring with confidence
  • 24. Demonstrate TDD impact on design decisions </li></ul></ul>
  • 25. TDD: Live Code Example <ul><li>Code example will test a fictional math tutor application </li><ul><li>Calculator class
  • 26. Tutor class (consumes calculator) </li></ul></ul>
  • 27. TDD: Live Code Example <ul><li>Calculator class </li><ul><li>Adds one integer to another
  • 28. Throws exceptions in the following cases: </li><ul><li>Non-integer arguments provided
  • 29. Integer overflow
  • 30. Integer underflow </li></ul><li>Code to interface not implementation </li><ul><li>Tutor_Calculator_Interface
  • 31. Tutor_Calculator_IntegerCalculator </li></ul></ul></ul>
  • 32. TDD: Live Code Example <ul><li>Tutor class </li><ul><li>Verifies correct responses
  • 33. Uses calculator class to test responses
  • 34. Favors composition over inheritance
  • 35. Tutor_MathTutor </li></ul></ul>
  • 36. TDD: Live Code Example <ul><li>We'll be using PHPUnit
  • 37. PHPUnit will be configured with phpunit.xml
  • 38. phpunit.xml: </li><ul><li>Calls bootstrap.php
  • 39. Tells PHPUnit where to look for our tests
  • 40. Code coverage and testdox reports </li></ul><li>bootstrap.php: </li><ul><li>Adds our library to the include path
  • 41. Registers a simple autoloader </li></ul></ul>
  • 42. LET'S GET IT ON!
  • 43. Resources <ul><li>Test Driven Development at Wikipedia - http://bit.ly/9Aa3Xr
  • 44. PHPUnit - http://www.phpunit.de/
  • 45. Xdebug - http://www.xdebug.org/
  • 46. The code example in this presentation was adapted for PHP from Przemysław Bielicki's TDD video tutorial at Agile Software Development. - http://bit.ly/byDZOA </li></ul>
  • 47. Thanks! <ul>[email_address] @JeremyKendall http://jeremykendall.net </ul>

×