• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
TDD in PHP - A Brief Example (Nashville PHP 2010-10-12)
 

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

on

  • 3,526 views

 

Statistics

Views

Total Views
3,526
Views on SlideShare
3,526
Embed Views
0

Actions

Likes
2
Downloads
30
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

    • TDD in PHP: A Brief Example
    • About Me Jeremy Kendall PHP Developer since 2001 Organizer Memphis PHP Contributor to FRAPI project (getfrapi.com) [email_address] @JeremyKendall http://jeremykendall.net
    • TDD in PHP: A Brief Example Test Driven Development, you say?
    • Frankly, my dear . . .
    • Why You Should Give A Damn
        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
    • What is TDD?
      • From Wikipedia:
      • ” Test Driven Development (TDD) is a software development process that relies on the repetition of a very short development cycle . . .”
    • TDD Development Process
      • 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
    • TDD: The Benefits
      • High cohesion, loose coupling
      • Confidence
      • Faster time to resolution
      • Documentation
    • TDD: The Drawbacks
      • Tests only cover what you think should be tested
      • False sense of confidence
      • Without management and team buy-in, TDD is DOA
    • TDD: Live Code Example
        Live Coding? Really? Why?
    • TDD: Live Code Example
      • Goals
        • Practical example of TDD in action
        • Demonstrate refactoring with confidence
        • Demonstrate TDD impact on design decisions
    • TDD: Live Code Example
      • Code example will test a fictional math tutor application
        • Calculator class
        • Tutor class (consumes calculator)
    • TDD: Live Code Example
      • Calculator class
        • Adds one integer to another
        • Throws exceptions in the following cases:
          • Non-integer arguments provided
          • Integer overflow
          • Integer underflow
        • Code to interface not implementation
          • Tutor_Calculator_Interface
          • Tutor_Calculator_IntegerCalculator
    • TDD: Live Code Example
      • Tutor class
        • Verifies correct responses
        • Uses calculator class to test responses
        • Favors composition over inheritance
        • Tutor_MathTutor
    • TDD: Live Code Example
      • We'll be using PHPUnit
      • PHPUnit will be configured with phpunit.xml
      • phpunit.xml:
        • Calls bootstrap.php
        • Tells PHPUnit where to look for our tests
        • Code coverage and testdox reports
      • bootstrap.php:
        • Adds our library to the include path
        • Registers a simple autoloader
    • LET'S GET IT ON!
    • Resources
      • Test Driven Development at Wikipedia - http://bit.ly/9Aa3Xr
      • PHPUnit - http://www.phpunit.de/
      • Xdebug - http://www.xdebug.org/
      • 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
    • Thanks!
        [email_address] @JeremyKendall http://jeremykendall.net