SlideShare a Scribd company logo
1 of 35
Test Driven DevelopmentIn Action! by Jon Kruger
What is Test Driven Development? A software development technique where you write automated unit tests before you write your implementation code A technique for ensuring good quality and good design Awesome!
Example of a unit test [TestFixture] public class When_using_the_calculator {     [Test]     public void Should_add_two_numbers()     { int result = new Calculator().Add(2, 3); result.ShouldEqual(5);     } }
Unit Tests vs. Integration Tests Unit tests: Tests a small unit of functionality Mock or “fake out” external dependencies (e.g. databases) Run fast Integration tests: Test the whole system working together Can run slow Can be brittle
Unit Testing Frameworks .NET NUnit, MSTest, MBUnit, xUnit, MSpec Java JUnit, TestNG Ruby RSpec, Test::Unit, Shoulda
The TDD Process Write a test (or tests) for something.  Since you haven’t written the implementation code yet, the tests should fail. Write just enough code to get the test to pass. Move on or refactor “Red – Green – Refactor”
A Series of Translations
Code!
Benefits of TDD We know that our code is working!
Benefits of TDD We know that our code will continue to work
Benefits of TDD We didn’t write bugs
Benefits of TDD We know when we are done
Benefits of TDD We incrementally translated the requirements
Behavior Driven Development Testing the behavior of the system (not just data returned by a method) Defining what it means for your system to work correctly (not just verifying that code works)
Benefits of TDD Concentrate on the requirements/tests, then concentrate on implementation
Benefits of TDD We only wrote as much code as we needed to make the tests pass
Benefits of TDD Our tests helped us design our code
“Clean code that works is the goal of Test Driven Development.” -- Ron Jeffries
Benefits of TDD We had to write testable code
Benefits of TDD Our tests are documentation of what our code does
Benefits of TDD Our tests are documentation of what our code does Someday someone other than you will have to understand your code Someday you will wonder what your code was supposed to do Living, breathing documentation!
Benefits of TDD We can quickly regression test our code
Benefits of TDD We can quickly regression test our code Fewer bugs Able to release more often Less time spent doing manual testing Prevent our app from becoming “legacy code”
Benefits of TDD Peace of mind!
But I don’t have time to do TDD! I don’t have time to fix bugs I don’t have time to constantly step through code to see if it’s all working I don’t have time to figure out what your code is supposed to do I don’t have time to figure out if my changes will break something in your code I don’t have time to rewrite code Think long-term, not short-term!!
“If I don't need to make it work, I can go a lot faster.” -- Kent Beck
The Cost of Unit Testing Source: http://blog.typemock.com/2009/03/cost-of-test-driven-development.html
The Cost of Not Unit Testing Source: http://www.riceconsulting.com/public_pdf/STBC-WM.pdf
Resources - Cost of unit testing Microsoft Research – “Realizing quality improvement through test driven development: results and experiences of four industrial teams” http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf Cost of Testing, by MiskoHevery (Agile Coach/Java developer at Google) http://misko.hevery.com/2009/10/01/cost-of-testing/ TDD Derangement Syndrome, by Uncle Bob Martin http://blog.objectmentor.com/articles/2009/10/07/tdd-derangement-syndrome
Resources - Tools .NET NUnit – http://nunit.org Should – http://should.codeplex.com Java JUnit – http://junit.org TestNG – http://testng.org Ruby RSpec – http://rspec.info, or gem install rspec Specs2Tests – http://github.com/jonkruger/specs2tests
Resources – Learning TDD Behavior Driven Development http://www.code-magazine.com/article.aspx?quickid=0805061&page=1 So How do You Introduce TDD into an Organization or Team?, by Jeremy Miller http://codebetter.com/blogs/jeremy.miller/archive/2006/06/27/146899.aspx How to get started with TDD, by MiskoHevery (Java examples) http://misko.hevery.com/2009/11/17/how-to-get-started-with-tdd/ TDD Starter Kit – Sample Projects and Links (C# examples) http://jonkruger.com/blog/2009/07/23/tdd-starter-kit-sample-projects-and-links/ Pair Programming Bot http://pairprogrammingbot.com/
Resources – Books The Art of Unit Testing by Roy Osherove Test Driven Development: By Example by Kent Beck Test Driven Development: A Practical Guide by David Astels The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends by David Chelimsky, Dave Astels, et. al.
Resources – Practice! String Calculator kata http://osherove.com/tdd-kata-1/ Bowling Game kata http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata Prime Factors kata http://www.butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata Greed game (part of the Ruby koans) http://github.com/edgecase/ruby_koans Katacasts(watch screencasts of people doing various katas) http://www.katacasts.com/
Resources – Training TDD Boot Camp (.NET) http://tddbootcamp.com Pillar Technology (Java) http://pillartechnology.com EdgeCase (Ruby on Rails) http://edgecase.com
My Info Email: jon@jonkruger.com Twitter: @JonKruger Blog: http://jonkruger.com/blog These slides:http://tinyurl.com/tdd-in-action

More Related Content

What's hot

Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
toteb5
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Dhaval Dalal
 

What's hot (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD)
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven Development
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpec
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed Shreef
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
TDD That Was Easy!
TDD   That Was Easy!TDD   That Was Easy!
TDD That Was Easy!
 

Viewers also liked

Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Zohirul Alam Tiemoon
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
Confiz
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software Testing
Nishant Worah
 

Viewers also liked (20)

Shallow Depth of Tests Scallable BDD and TDD
Shallow Depth of Tests Scallable BDD and TDDShallow Depth of Tests Scallable BDD and TDD
Shallow Depth of Tests Scallable BDD and TDD
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
TDD - Short for Test Driven Development!
TDD - Short for Test Driven Development!TDD - Short for Test Driven Development!
TDD - Short for Test Driven Development!
 
What did AlphaGo do to beat the strongest human Go player?
What did AlphaGo do to beat the strongest human Go player?What did AlphaGo do to beat the strongest human Go player?
What did AlphaGo do to beat the strongest human Go player?
 
Introducing Elixir the easy way
Introducing Elixir the easy wayIntroducing Elixir the easy way
Introducing Elixir the easy way
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
How fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practiceHow fast ist it really? Benchmarking in practice
How fast ist it really? Benchmarking in practice
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
The Engines of Software Development: Testing and Test Driven Development
The Engines of Software Development: Testing and Test Driven DevelopmentThe Engines of Software Development: Testing and Test Driven Development
The Engines of Software Development: Testing and Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Java 201 Intro to Test Driven Development in Java
Java 201   Intro to Test Driven Development in JavaJava 201   Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
On the Care and Feeding of Feedback Cycles
On the Care and Feeding of Feedback CyclesOn the Care and Feeding of Feedback Cycles
On the Care and Feeding of Feedback Cycles
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software Testing
 

Similar to Test-Driven Development In Action

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
bhochhi
 

Similar to Test-Driven Development In Action (20)

TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012xUnit and TDD: Why and How in Enterprise Software, August 2012
xUnit and TDD: Why and How in Enterprise Software, August 2012
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Python and test
Python and testPython and test
Python and test
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.Understanding TDD - theory, practice, techniques and tips.
Understanding TDD - theory, practice, techniques and tips.
 
Tdd
TddTdd
Tdd
 
Automated Unit Testing and TDD
Automated Unit Testing and TDDAutomated Unit Testing and TDD
Automated Unit Testing and TDD
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
 
Test-driven development & Behavior-driven development basics
Test-driven development & Behavior-driven development basicsTest-driven development & Behavior-driven development basics
Test-driven development & Behavior-driven development basics
 
Automated tests
Automated testsAutomated tests
Automated tests
 
Outside-in Testing in Vue with Cypress
Outside-in Testing in Vue with CypressOutside-in Testing in Vue with Cypress
Outside-in Testing in Vue with Cypress
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

More from Jon Kruger (9)

The Business of You: 10 Steps To Run Your Career Like a Business
The Business of You: 10 Steps To Run Your Career Like a BusinessThe Business of You: 10 Steps To Run Your Career Like a Business
The Business of You: 10 Steps To Run Your Career Like a Business
 
Developing an Automated Testing Strategy
Developing an Automated Testing StrategyDeveloping an Automated Testing Strategy
Developing an Automated Testing Strategy
 
A Whole Team Approach To Testing
A Whole Team Approach To TestingA Whole Team Approach To Testing
A Whole Team Approach To Testing
 
An ATDD Case Study
An ATDD Case StudyAn ATDD Case Study
An ATDD Case Study
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
Productivity Boosters for .NET Developers
Productivity Boosters for .NET DevelopersProductivity Boosters for .NET Developers
Productivity Boosters for .NET Developers
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID Principles
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design Principles
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Test-Driven Development In Action

  • 1. Test Driven DevelopmentIn Action! by Jon Kruger
  • 2. What is Test Driven Development? A software development technique where you write automated unit tests before you write your implementation code A technique for ensuring good quality and good design Awesome!
  • 3. Example of a unit test [TestFixture] public class When_using_the_calculator { [Test] public void Should_add_two_numbers() { int result = new Calculator().Add(2, 3); result.ShouldEqual(5); } }
  • 4. Unit Tests vs. Integration Tests Unit tests: Tests a small unit of functionality Mock or “fake out” external dependencies (e.g. databases) Run fast Integration tests: Test the whole system working together Can run slow Can be brittle
  • 5. Unit Testing Frameworks .NET NUnit, MSTest, MBUnit, xUnit, MSpec Java JUnit, TestNG Ruby RSpec, Test::Unit, Shoulda
  • 6. The TDD Process Write a test (or tests) for something. Since you haven’t written the implementation code yet, the tests should fail. Write just enough code to get the test to pass. Move on or refactor “Red – Green – Refactor”
  • 7. A Series of Translations
  • 9. Benefits of TDD We know that our code is working!
  • 10. Benefits of TDD We know that our code will continue to work
  • 11. Benefits of TDD We didn’t write bugs
  • 12. Benefits of TDD We know when we are done
  • 13. Benefits of TDD We incrementally translated the requirements
  • 14. Behavior Driven Development Testing the behavior of the system (not just data returned by a method) Defining what it means for your system to work correctly (not just verifying that code works)
  • 15. Benefits of TDD Concentrate on the requirements/tests, then concentrate on implementation
  • 16. Benefits of TDD We only wrote as much code as we needed to make the tests pass
  • 17. Benefits of TDD Our tests helped us design our code
  • 18. “Clean code that works is the goal of Test Driven Development.” -- Ron Jeffries
  • 19. Benefits of TDD We had to write testable code
  • 20. Benefits of TDD Our tests are documentation of what our code does
  • 21. Benefits of TDD Our tests are documentation of what our code does Someday someone other than you will have to understand your code Someday you will wonder what your code was supposed to do Living, breathing documentation!
  • 22. Benefits of TDD We can quickly regression test our code
  • 23. Benefits of TDD We can quickly regression test our code Fewer bugs Able to release more often Less time spent doing manual testing Prevent our app from becoming “legacy code”
  • 24. Benefits of TDD Peace of mind!
  • 25. But I don’t have time to do TDD! I don’t have time to fix bugs I don’t have time to constantly step through code to see if it’s all working I don’t have time to figure out what your code is supposed to do I don’t have time to figure out if my changes will break something in your code I don’t have time to rewrite code Think long-term, not short-term!!
  • 26. “If I don't need to make it work, I can go a lot faster.” -- Kent Beck
  • 27. The Cost of Unit Testing Source: http://blog.typemock.com/2009/03/cost-of-test-driven-development.html
  • 28. The Cost of Not Unit Testing Source: http://www.riceconsulting.com/public_pdf/STBC-WM.pdf
  • 29. Resources - Cost of unit testing Microsoft Research – “Realizing quality improvement through test driven development: results and experiences of four industrial teams” http://research.microsoft.com/en-us/projects/esm/nagappan_tdd.pdf Cost of Testing, by MiskoHevery (Agile Coach/Java developer at Google) http://misko.hevery.com/2009/10/01/cost-of-testing/ TDD Derangement Syndrome, by Uncle Bob Martin http://blog.objectmentor.com/articles/2009/10/07/tdd-derangement-syndrome
  • 30. Resources - Tools .NET NUnit – http://nunit.org Should – http://should.codeplex.com Java JUnit – http://junit.org TestNG – http://testng.org Ruby RSpec – http://rspec.info, or gem install rspec Specs2Tests – http://github.com/jonkruger/specs2tests
  • 31. Resources – Learning TDD Behavior Driven Development http://www.code-magazine.com/article.aspx?quickid=0805061&page=1 So How do You Introduce TDD into an Organization or Team?, by Jeremy Miller http://codebetter.com/blogs/jeremy.miller/archive/2006/06/27/146899.aspx How to get started with TDD, by MiskoHevery (Java examples) http://misko.hevery.com/2009/11/17/how-to-get-started-with-tdd/ TDD Starter Kit – Sample Projects and Links (C# examples) http://jonkruger.com/blog/2009/07/23/tdd-starter-kit-sample-projects-and-links/ Pair Programming Bot http://pairprogrammingbot.com/
  • 32. Resources – Books The Art of Unit Testing by Roy Osherove Test Driven Development: By Example by Kent Beck Test Driven Development: A Practical Guide by David Astels The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and Friends by David Chelimsky, Dave Astels, et. al.
  • 33. Resources – Practice! String Calculator kata http://osherove.com/tdd-kata-1/ Bowling Game kata http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata Prime Factors kata http://www.butunclebob.com/ArticleS.UncleBob.ThePrimeFactorsKata Greed game (part of the Ruby koans) http://github.com/edgecase/ruby_koans Katacasts(watch screencasts of people doing various katas) http://www.katacasts.com/
  • 34. Resources – Training TDD Boot Camp (.NET) http://tddbootcamp.com Pillar Technology (Java) http://pillartechnology.com EdgeCase (Ruby on Rails) http://edgecase.com
  • 35. My Info Email: jon@jonkruger.com Twitter: @JonKruger Blog: http://jonkruger.com/blog These slides:http://tinyurl.com/tdd-in-action

Editor's Notes

  1. -Lower stress level!-Not wasting time setting breakpoints and testing the debugger
  2. -If you test with the debugger, how do you know the next day if your code is still working?-Someone else is going to change your code someday, so now you don’t have to worry about them breaking your stuff.
  3. Bugs cost money to find, money to write up, money to fixThe negative impact caused by bugs can be really expensive
  4. Software development is a series of translations – we need to get from an idea in someone’s head to working software. The best way to not lose sight of that goal is to do small “translations” that will ensure that we stay focused on the original goal.
  5. -Think about one thing at a time… much easier, less stressful
  6. We won’t waste time on code that we don’t need to writeHelps prevent gold plating
  7. -When you write testable code, you are less likely to have tight coupling -Our tests help us name our methods well
  8. -If you write your tests after your implementation code, you might end up with a situation where it’s difficult to test it
  9. I can’t explain this one, you have to experience it for yourself!