Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Unit Testing PHP

799 views

Published on

Some slides from a presentation at work. Blog post: http://pointbeing.net/weblog/2008/08/presentations-on-slideshare.html Demo code: http://demo.pointbeing.net/unittesting/

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Unit Testing PHP

  1. 1. Unit Testing PHP
  2. 2. Unit Testing <ul><li>Making sure that stuff works </li></ul><ul><li>Boring :-( </li></ul><ul><li>What is Unit Testing? </li></ul><ul><li>Writing code to make sure that your code works </li></ul><ul><li>Part of the development phase, not the testing phase </li></ul><ul><li>Fun :-D </li></ul><ul><ul><li>What is testing? </li></ul></ul>
  3. 3. Examples <ul><li>The Simplest Test Ever Written </li></ul><ul><li>Something a bit more exciting </li></ul><ul><li>http://demo.pointbeing.net/unittesting/ </li></ul>
  4. 4. Test-Driven Development <ul><li>Write the test first, then write the code to pass the test </li></ul><ul><li>Mantra: Red, Green, Refactor </li></ul><ul><li>Code is guaranteed to have full test coverage </li></ul>
  5. 5. Bug Fixing Strategy <ul><li>Write the smallest possible test that exposes the bug – formalise the bug as a failing test (red)‏ </li></ul><ul><li>Do whatever it takes to make the test pass (green)‏ </li></ul><ul><li>Tidy up and remove duplication (refactor) </li></ul><ul><li>The bug is fixed, and can never reappear...so long as you run the tests! </li></ul>
  6. 6. Benefits <ul><li>You can be confident that your code does what it's supposed to </li></ul><ul><li>Code is cleaner, classes and methods are simpler – code suddenly has “units” </li></ul><ul><li>Formal refactoring becomes a possibility </li></ul><ul><li>Time spent debugging is decimated; bugs do not magically reappear </li></ul><ul><li>You CV is stronger, and you earn more </li></ul>

×