Your SlideShare is downloading. ×
0
TDD in PHP:  A Brief Example
About Me Jeremy Kendall PHP Developer since 2001 Organizer Memphis PHP Contributor to FRAPI project (getfrapi.com) [email_...
TDD in PHP: A Brief Example Test Driven Development, you say?
Frankly, my dear . . .
Why You Should Give A Damn <ul>Test Driven Development is perhaps one of the best and fastest ways to improve your underst...
What is TDD? <ul><li>From Wikipedia:
” Test Driven Development (TDD)  is a software development process that relies on the repetition of a very short developme...
TDD Development Process <ul><li>Write a test
Run all tests, watch new test fail
Write just enough code to make the test pass
Run all tests, watch new test pass
Lather, rinse, repeat . . .
Refactor </li></ul>
TDD: The Benefits <ul><li>High cohesion, loose coupling
Confidence
Faster time to resolution
Upcoming SlideShare
Loading in...5
×

Tdd in php a brief example

2,426

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
2,426
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Tdd in php a brief example"

  1. 1. TDD in PHP: A Brief Example
  2. 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. 3. TDD in PHP: A Brief Example Test Driven Development, you say?
  4. 4. Frankly, my dear . . .
  5. 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. </ul>
  6. 6. What is TDD? <ul><li>From Wikipedia:
  7. 7. ” Test Driven Development (TDD) is a software development process that relies on the repetition of a very short development cycle . . .” </li></ul>
  8. 8. TDD Development Process <ul><li>Write a test
  9. 9. Run all tests, watch new test fail
  10. 10. Write just enough code to make the test pass
  11. 11. Run all tests, watch new test pass
  12. 12. Lather, rinse, repeat . . .
  13. 13. Refactor </li></ul>
  14. 14. TDD: The Benefits <ul><li>High cohesion, loose coupling
  15. 15. Confidence
  16. 16. Faster time to resolution
  17. 17. Documentation </li></ul>
  18. 18. TDD: The Drawbacks <ul><li>Tests only cover what you think should be tested
  19. 19. False sense of confidence
  20. 20. Without management and team buy-in, TDD is DOA </li></ul>
  21. 21. TDD: Live Code Example <ul>Live Coding? Really? Why? </ul>
  22. 22. TDD: Live Code Example <ul><li>Code example will test a integer calculator for a fictional Math Tutor application
  23. 23. Requirements </li><ul><li>Will add one integer to another
  24. 24. Throws exceptions in the following cases: </li><ul><li>Non-integer arguments provided
  25. 25. Integer overflow
  26. 26. Integer underflow </li></ul></ul></ul>
  27. 27. TDD: Live Code Example <ul><li>We'll be using PHPUnit
  28. 28. PHPUnit will be configured with phpunit.xml
  29. 29. phpunit.xml: </li><ul><li>Calls bootstrap.php
  30. 30. Tells PHPUnit where to look for our tests
  31. 31. Code coverage and testdox reports </li></ul><li>bootstrap.php: </li><ul><li>Adds our library to the include path
  32. 32. Registers a simple autoloader </li></ul></ul>
  33. 33. TDD: Live Code Example <ul><li>Design Decisions </li><ul><li>PEAR naming convention
  34. 34. Interface, not implementation
  35. 35. Interface: Tutor_Calculator_Interface
  36. 36. Implementation: Tutor_Calculator_IntegerCalculator </li></ul></ul>
  37. 37. LET'S GET IT ON!
  38. 38. Resources <ul><li>Test Driven Development at Wikipedia - http://bit.ly/9Aa3Xr
  39. 39. PHPUnit - http://www.phpunit.de/
  40. 40. Xdebug - http://www.xdebug.org/
  41. 41. 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>
  42. 42. Thanks! <ul>[email_address] @JeremyKendall http://jeremykendall.net </ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×