tdd immersion n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
TDD Immersion PowerPoint Presentation
Download Presentation
TDD Immersion

Loading in 2 Seconds...

play fullscreen
1 / 35

TDD Immersion - PowerPoint PPT Presentation


  • 81 Views
  • Uploaded on

TDD Immersion. Jon Kruger Twitter: @ JonKruger Email: jon@jonkruger.com Blog: http://jonkruger.com/blog. Schedule. 1:30-2:00 Intro to TDD 2:05-2:35 Writing Testable Code 2:40-3:00 Mocking with Moq 3:05-3:55 Dependency Injection with StructureMap

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'TDD Immersion' - veronica-fowler


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
tdd immersion

TDD Immersion

Jon Kruger

Twitter: @JonKruger

Email: jon@jonkruger.com

Blog: http://jonkruger.com/blog

schedule
Schedule

1:30-2:00 Intro to TDD

2:05-2:35 Writing Testable Code

2:40-3:00 Mocking with Moq

3:05-3:55 Dependency Injection with StructureMap

4:00-4:30 Looking at sample code, wrap-up

4:30-5:30 Live coding action!!!

case studies
Case Studies

We don’t know what code is supposed to do

“The Legacy Codebase”

case studies1
Case Studies

We can’t prove that our code is working without someone manually verifying that it works

“The Last Minute Change”

case studies2
Case Studies

Bugs are a waste of time

“The Infinite Loop of Bugs”

case studies3
Case Studies

Low standards of quality

“Throwing It Over the Wall”

case studies4
Case Studies

Bugs can be really expensive to fix

“Explosions and Blackouts”

case studies5
Case Studies

Over time, code bases tend to become more chaotic and painful to work with

“The Maintenance Nightmare”

how can we solve these problems
How can we solve these problems?
  • We need a way to ensure that our code is working
  • We need a way to ensure that our code will continue to work after someone changes it
  • We need a way to figure out what code is supposed to do
  • We need to make software development less stressful
what is test driven development
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
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);

}

}

types of tests
Types of 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
  • Functional/Acceptance tests
    • End-to-end tests that test that a feature meets the needs of the business
  • Manual tests
unit testing frameworks
Unit Testing Frameworks
  • NUnit
  • MSTest
  • MBUnit
  • xUnit
  • MSpec
the tdd process
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”

benefits of tdd
Benefits of TDD

We know that our code is working!

benefits of tdd1
Benefits of TDD

We know that our code will continue to work

benefits of tdd2
Benefits of TDD

We didn’t write bugs

benefits of tdd3
Benefits of TDD

We know when we are done

benefits of tdd4
Benefits of TDD

We incrementally translated the requirements

behavior driven development
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 tdd5
Benefits of TDD

Concentrate on the requirements/tests, then concentrate on implementation

benefits of tdd6
Benefits of TDD

We only wrote as much code as we needed to make the tests pass

benefits of tdd7
Benefits of TDD

Our tests helped us design our code

benefits of tdd8
Benefits of TDD

We had to write testable code

benefits of tdd9
Benefits of TDD

We couldn’t cheat and not write the tests

benefits of tdd10
Benefits of TDD

Our tests are documentation of what our code does

benefits of tdd11
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 tdd12
Benefits of TDD

We can quickly regression test our code

benefits of tdd13
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 tdd14
Benefits of TDD

Peace of mind!