1 / 11

Introduction to TDD

Introduction to TDD. Sean Chambers April 2 nd 2008. About Sean. Senior Developer at Flagler County Schools for 5 years Lead Developer/Partner of StuntJuice.com Owner Hybrid Software, Educational Software

teige
Download Presentation

Introduction to TDD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to TDD Sean Chambers April 2nd 2008

  2. About Sean • Senior Developer at Flagler County Schools for 5 years • Lead Developer/Partner of StuntJuice.com • Owner Hybrid Software, Educational Software • Contributor to various open source projects (Castle Project, Nhibernate, NUnit, NBehave) • Practicing TDD for 2 years • Domain Driven Design for 1 year • Blog: http://schambers.lostechies.com • Twitter: schambers

  3. Why use TDD? • Software requirements are constantly changing • Changes to the codebase can introduce bugs that you may not even know exist • Test Driven Development aims to have a constant suite of tests to verify that changes do not introduce any new bugs and/or change behavior

  4. Overview • TDD is a technique for developing software that focuses on writing tests to drive functionality of the software being developed. It provides a test bench that provides constant feedback about your codebase. Therefore, impacts to the code from changes can be viewed system wide all the time • An overview of testing software • unit tests/state testing • integration testing (CruiseControl/TeamCity/Draco.net)

  5. The TDD Mantra • The TDD Mantra is “Red-Green-Refactor” • RED • Write a test for a piece of functionality so that it is failing • Green • Write JUST ENOUGH code to make the test pass. (KISS) • Refactor • Reorganize code to enforce DRY/SRP etc.. • By far the most difficult step

  6. What tools do I need? • The best part is: they are all open source! • Test Runner • Nunit • MbUnit • Test Runners within VS • TestDriven.Net • ReSharper Test Runner (used in this presentation)

  7. What does TDD do for you? • A form of documentation with unit tests that can convey what the system does. • Loose Coupling of Modules • Enforces YAGNI and KISS in the form of very small iterative steps • Rarely need to invoke a debugger, some even say they no longer need one! This dramatically speeds up development • Although more code is actually written with TDD, implementation time is actually shorter when you get up to speed with TDD

  8. TDD Video Store Sample • Sample application with TDD for a video store. With the following User Stories • A Video has a Title, Description and a UPC • A Rental has a checkout date and a return date • A Rental is associated with a Video and a Customer • A Customer can checkout a video from the Video Store which creates a rental for the customer • A Manager can view overdue Rentals for a Customer • A Manager can view all Rentals for a Customer

  9. Other types of Tests • Bug fixing tests • Database tests with NHibernate • MVC Controller tests with MonoRail/ASP.NetMVC

  10. What else to TDD? • ORM IoC/Dependency Injection • Stubs and Mocks • Different Project Structures to promote new techniques • Code Coverage tells you how much of your code has tests for it, can be misleading however • Continuous Integration with CruiseControl.NET/TeamCity to run tests after every checkin • Some projects created using TDD

  11. Additional Resources • schambers80@gmail.com • http://schambers.lostechies.com • http://del.icio.us/darckode

More Related