Test Driven Development

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Test Driven Development - Presentation Transcript

    1. Test Driven Development (TDD)
      What TDD is and is not
      Basics of how to do TDD
      Steps
      Tools
      Where to go to learn more
      Can it be used in your projects
      1
      7/9/2009
    2. What is it?
      A design (not a testing) technique
      Formally defined as a practice in 2001
      Used in both agile and extreme programming
      Best used on new projects with less than a few dozen developers
      Can be used to add new features to an existing project that didn’t originally use TDD
      2
      7/9/2009
    3. Test Types
      Programmer
      NOT unit tests
      Ideally written in same language as the application
      Tool: NUnit or JUnit
      Customer
      A.k.a. Acceptance or functional tests
      Written in a language the customer understands
      Tool: FIT – Framework for Integrated Test
      Tester Tests
      Traditional QA-type tests
      Outside scope of TDD
      3
      7/9/2009
    4. Basic Rules
      Before writing any code, write the test for it first
      Implement the feature
      Eliminate duplicate code and refine the design
      4
      7/9/2009
    5. Basic Rules: Write the Test
      Use a tool such as NUnit or JUnit
      The test will define the public interface
      Focus is on how to use your interface
      5
      7/9/2009
    6. Basic Rules: Implement the Feature
      Write just enough to satisfy the requirement
      Appropriate for the skill level of the one who will be maintaining it
      Passes all tests
      Communicates intent as clearly as possible
      Duplication is allowed
      Has the smallest number of classes
      Has the smallest number of methods
      6
      7/9/2009
    7. Basic Rules: Eliminate Duplicate Code
      Eliminate duplicate code and refine the design
      Unless it shows the intent of the design more clearly
      Avoids inconsistency
      Use refactoring
      Definition: Improving code without changing its functionality
      Complexity can be added if it is done to remove duplication
      7
      7/9/2009
    8. Steps
      Brainstorm list of tests for a feature
      Write them down
      Cross them off as they’re implemented
      You’re finished when all tests have been crossed off
      Perform “Red/Green/Refactor” process
      Red/Green refers to test results
      8
      7/9/2009
    9. Red/Green/Refactor Process
      Choose a test from the list
      Write the test code
      Compile the test code – this should fail
      Implement just enough to compile
      Run the test and see it fail
      Implement just enough to make the test pass
      Run the test and verify it passes
      Refactor for clarity and to eliminate duplication
      Brainstorm additional tests
      Repeat
      9
      7/9/2009
    10. Red/Green/Refactor Process
      The steps are intentionally very small
      Makes it easier to find a mistake
      Can speed up development
      Less time spent debugging
      Confidence in the code that has already been written
      10
      7/9/2009
    11. Refactoring
      Improving code without changing its functionality
      Can be thought of as patterns for changing existing code
      Focus is on making existing code cleaner and easier to understand
      Examples from “Refactoring” by Martin Fowler
      Extract Method
      Inline Method
      (over 70 more)
      Tools available for C#, Java, Visual Basic and a few other languages (see www.refactoring.com)
      11
      7/9/2009
    12. Tools: NUnit
      Framework for creating automated tests
      NUnit is for .NET; JUnit for Java, vbUnit for Visual Basic and CppUnit for C++
      Has both GUI and command-line interfaces
      Tests can be run by an automated build process
      Free
      12
      7/9/2009
    13. NUnit Example
      Passed tests are green, failures are red and ignored tests are yellow
      13
      7/9/2009
    14. NUnit Example
      Reference nunit.Framework.dll
      Add TestFixture class.
      Run using nunit-gui.exe
      14
      7/9/2009
    15. Tools: FIT (Framework for Integrated Test)
      Framework for creating customer acceptance tests
      Uses HTML tables created using MS Word, MS Excel
      Customer shows expected results in the table
      Developer adds FIT Fixture
      FIT updates HTML table to show actual vs. expected results
      Has both GUI and command-line interfaces
      Free
      15
      7/9/2009
    16. FIT Example
      Cunningham, Ward. Framework for Integrated Test. September 7, 2002. http://fit.c2.com
      Successes and failures are highlighted
      Easy for technical and non-technical users to understand
      16
      7/9/2009
    17. FIT Example
      Cunningham, Ward. Introduction to FIT. Framework for Integrated Test. September 7, 2002. http://fit.c2.com/wiki.cgi?IntroductionToFit
      The fixture is fed data from the HTML table
      17
      7/9/2009
    18. Summary
      TDD is a design technique
      Red/Green/Refactor
      Tools: NUnit and FIT
      Appropriate for your project?
      18
      7/9/2009
    19. Where to Get More Information
      Online
      www.TestDriven.com
      www.nunit.org or www.junit.org
      nunitforms.sourceforge.net
      fit.c2.com
      www.refactoring.com
      www.sourceforge.net (NUnitForms, NUnitAsp)
      Books
      “Test-Driven Development in Microsoft .NET”, by James W. Newkirk and Alexei A. Vorontsov (Microsoft Press, 2004)
      “Test-Driven Development: By Example”, by Kent Beck (Addison Wesley, 2003)
      “Refactoring: Improving the Design of Existing Code”, by Martin Fowler (Addison-Wesley, 1999)
      19
      7/9/2009

    + Intertech TrainingIntertech Training, 4 months ago

    custom

    355 views, 1 favs, 0 embeds more stats

    http://www.Intertech.com

    This is a technical pre more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 355
      • 355 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 0
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories