ASPE Test Driven Development.053013

download ASPE Test Driven Development.053013

of 28

Transcript of ASPE Test Driven Development.053013

  • 7/27/2019 ASPE Test Driven Development.053013

    1/28

    Test Driven Development

    A Webinar with Kevin Klinemeier

  • 7/27/2019 ASPE Test Driven Development.053013

    2/28

    Kevin Klinemeier

    Agile Trainer and Coach

    Software Developer / Architect / Tester

    @agilekevin

    [email protected]

  • 7/27/2019 ASPE Test Driven Development.053013

    3/28

    Agenda

    TDD Overview Expected Values

    Test Driven Design Additional tools

    Getting Started

  • 7/27/2019 ASPE Test Driven Development.053013

    4/28

    TDD

    Spend ~3 days writing tests, then start the realwork.

    Tell your PMO you need more time

    Fire your QA staff: no manual testing orsystem needed

  • 7/27/2019 ASPE Test Driven Development.053013

    5/28

    Unit Testing

    Testing of units, by code One class or method

    Very few dependencies

    Self-determining no interpretation needed

  • 7/27/2019 ASPE Test Driven Development.053013

    6/28

    Categorize the Activity

  • 7/27/2019 ASPE Test Driven Development.053013

    7/28

    Red-green-refactor

    CreateaTest

    MakeaChange

    RunaTest

    Refactor

    RuntheTest

    Pas

    Fail

    Pass

    Fai

    Failure is success

    Success is the beginning

    Change is stability

  • 7/27/2019 ASPE Test Driven Development.053013

    8/28

    Value

    Why First?

    Why in Agile, whenwe could never

    justify it before?Source: Succeeding With Agile: Software Development using Scrum, Mike

    Cohn

  • 7/27/2019 ASPE Test Driven Development.053013

    9/28

    Value

  • 7/27/2019 ASPE Test Driven Development.053013

    10/28

    7 Wastes of Software Development

    Partially Done WorkExtra Features

    RelearningHandoffs

    Task Switching

    Delays

    Defects

    Examples of partially donework:

    Untested code

    Uncoded documentation

    Undocumented code

    Tests replace documentation

    They are TESTS!

  • 7/27/2019 ASPE Test Driven Development.053013

    11/28

    Only develop code thatsatisfies the tests.

    Working sets of tests

    are a signal to

    collaborate & review

    Partially Done WorkExtra Features

    RelearningHandoffs

    Task Switching

    Delays

    Defects

    7 Wastes of Software Development

  • 7/27/2019 ASPE Test Driven Development.053013

    12/28

    Tests show usagepatterns

    Always up-to-date

    Facilitates ping-pong-pairing

    Partially Done WorkExtra Features

    RelearningHandoffs

    Task Switching

    Delays

    Defects

    7 Wastes of Software Development

  • 7/27/2019 ASPE Test Driven Development.053013

    13/28

    Imbedded context

    dump

    Small tasks minimize

    potential forinterruption

    Partially Done WorkExtra Features

    RelearningHandoffs

    Task Switching

    Delays

    Defects

    7 Wastes of Software Development

  • 7/27/2019 ASPE Test Driven Development.053013

    14/28

  • 7/27/2019 ASPE Test Driven Development.053013

    15/28

    Finds bugs early

    Jump-starts defect

    resolution to

    integration layer

    Partially Done WorkExtra Features

    Relearning

    Handoffs

    Task Switching

    Delays

    Defects

    7 Wastes of Software Development

  • 7/27/2019 ASPE Test Driven Development.053013

    16/28

    Without TDD

  • 7/27/2019 ASPE Test Driven Development.053013

    17/28

  • 7/27/2019 ASPE Test Driven Development.053013

    18/28

    Test Last - Really

  • 7/27/2019 ASPE Test Driven Development.053013

    19/28

    Test Driven Development

  • 7/27/2019 ASPE Test Driven Development.053013

    20/28

    Test Driven Design

  • 7/27/2019 ASPE Test Driven Development.053013

    21/28

    Test Driven Design

    How do we make testing cheaper? Design fortestability.

    Program to Interfaces

    Dependency Injection/IOC

    High Cohesion

    Low Coupling

  • 7/27/2019 ASPE Test Driven Development.053013

    22/28

    Dynamic MocksRun-time implementation of interfaces

    accountService = new AccountService(mockCurrencyService);

    mocks = new Mockery();

    mockCurrencyService =

    mocks.NewMock();

    accountService = new AccountService(mockCurrencyService);

    Example:We want to test AccountService, but it needs an ICurrencyService.

    The concrete ICurrencyService needs lots of stuff.

    The ICurrencyService itself has 50 methods.

    Expect.Once.On(mockCurrencyService).

    Method("GetConversionRate").

    With("GBP", "CAD").

    Will(Return.Value(2.20));

  • 7/27/2019 ASPE Test Driven Development.053013

    23/28

    Continuous Integration

    CI

    Server

    Integration

    Build

    Machine

    ScriptedBuildIntegra onBuild

    Machine

    AutomatedUnitTes ng

    Transparency&Con nuousBuilds

  • 7/27/2019 ASPE Test Driven Development.053013

    24/28

    Code Coverage

    Track progress

    Target improvements

    Blame your co-

    workers

  • 7/27/2019 ASPE Test Driven Development.053013

    25/28

    BDD

    System Testing, System Integration Testing, and

    GUI Testing: TDD-style

    Toolset to parse natural language into automated

    actions, execute and report results

    Focuses on business-readable input and output.

    Maybe even business-writeable.

    Given (preconditions)When (actor+action)

    Then (observable result)

  • 7/27/2019 ASPE Test Driven Development.053013

    26/28

    Getting Started

    PracticeStick with it for at least 3 weeks

    Dont go it alone

    Measure progress & gaps with code coverage

    Expect learning pains

  • 7/27/2019 ASPE Test Driven Development.053013

    27/28

  • 7/27/2019 ASPE Test Driven Development.053013

    28/28

    Your Questions

    For any questions we arent

    able to cover, Ill beproviding a written response.

    Thanks!

    Kevin Klinemeier@agilekevin

    [email protected]