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

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentMireia Sangalo
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)nedirtv
 
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 2010guest5639fa9
 
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) CodeOps Technologies LLP
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
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 DevelopmentShawn Jones
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentDhaval Dalal
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
Agile Test Driven Development
Agile Test Driven DevelopmentAgile Test Driven Development
Agile Test Driven DevelopmentViraf Karai
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
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 RSpecBen Mabey
 
Test driven development
Test driven developmentTest driven development
Test driven developmentNascenia IT
 
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 ShreefAhmed Shreef
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOSPablo Villar
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
TDD That Was Easy!
TDD   That Was Easy!TDD   That Was Easy!
TDD That Was Easy!Kaizenko
 

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

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 TDDfabiopereirame
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
TDD - Short for Test Driven Development!
TDD - Short for Test Driven Development!TDD - Short for Test Driven Development!
TDD - Short for Test Driven Development!Bradley Cypert
 
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?Tobias Pfeiffer
 
Introducing Elixir the easy way
Introducing Elixir the easy wayIntroducing Elixir the easy way
Introducing Elixir the easy wayTobias Pfeiffer
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentjakubkoci
 
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 developmentStephen Fuqua
 
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 practiceTobias Pfeiffer
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
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 DevelopmentLemi Orhan Ergin
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentConsulthinkspa
 
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 Javaagorolabs
 
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)Lars Thorup
 
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 typesConfiz
 
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 CyclesElisabeth Hendrickson
 
Types of Software Testing
Types of Software TestingTypes of Software Testing
Types of Software TestingNishant 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

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 2012Justin Gordon
 
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 + EclipseUTC Fire & Security
 
Test driven development
Test driven developmentTest driven development
Test driven developmentnamkha87
 
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 Flexmichael.labriola
 
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.Malinda Kapuruge
 
Automated Unit Testing and TDD
Automated Unit Testing and TDDAutomated Unit Testing and TDD
Automated Unit Testing and TDDGreg Sohl
 
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 ...Abdelkrim Boujraf
 
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 basicsOleksii Prohonnyi
 
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 CypressJosh Justice
 
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)Gianluca Padovani
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Test driven development v1.0
Test driven development v1.0Test driven development v1.0
Test driven development v1.0Ganesh Kondal
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Developmentadrianmitev
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Developmentbhochhi
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentEffective
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentJohn Blanco
 

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

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 BusinessJon Kruger
 
Developing an Automated Testing Strategy
Developing an Automated Testing StrategyDeveloping an Automated Testing Strategy
Developing an Automated Testing StrategyJon Kruger
 
A Whole Team Approach To Testing
A Whole Team Approach To TestingA Whole Team Approach To Testing
A Whole Team Approach To TestingJon Kruger
 
An ATDD Case Study
An ATDD Case StudyAn ATDD Case Study
An ATDD Case StudyJon Kruger
 
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 DeveloperJon Kruger
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptJon Kruger
 
Productivity Boosters for .NET Developers
Productivity Boosters for .NET DevelopersProductivity Boosters for .NET Developers
Productivity Boosters for .NET DevelopersJon Kruger
 
Advanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesAdvanced Object-Oriented/SOLID Principles
Advanced Object-Oriented/SOLID PrinciplesJon Kruger
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design PrinciplesJon Kruger
 

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

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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 Scriptwesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

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!