• Save
Test Driven Development
Upcoming SlideShare
Loading in...5
×
 

Test Driven Development

on

  • 2,381 views

http://www.Intertech.com

http://www.Intertech.com

This is a technical presentation from Intertech on SharePoint.

Statistics

Views

Total Views
2,381
Views on SlideShare
2,374
Embed Views
7

Actions

Likes
3
Downloads
0
Comments
0

3 Embeds 7

http://www.linkedin.com 4
http://www.slideshare.net 2
https://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

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

Test Driven Development Test Driven Development Presentation Transcript

  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • NUnit Example
    Passed tests are green, failures are red and ignored tests are yellow
    13
    7/9/2009
  • NUnit Example
    Reference nunit.Framework.dll
    Add TestFixture class.
    Run using nunit-gui.exe
    14
    7/9/2009
  • 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
  • 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
  • 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
  • Summary
    TDD is a design technique
    Red/Green/Refactor
    Tools: NUnit and FIT
    Appropriate for your project?
    18
    7/9/2009
  • 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