• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
obs-tdd-intro
 

obs-tdd-intro

on

  • 493 views

PResentation done at

PResentation done at

Statistics

Views

Total Views
493
Views on SlideShare
493
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    obs-tdd-intro obs-tdd-intro Presentation Transcript

    • AMIR BARYLKO TDD INTRO ONLINE BUSINESS SYSTEMS APRIL 2011Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • WHO AM I? • Quality Expert • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentationsAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • TDD TRAINING • When: May 26 & 27 • More info: http://www.maventhought.com • Goal: Learn TDD with real hands on examplesAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • INTRO Why projects fail? Reality Check No more excuses Why TDD?Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • WHY PROJECTS FAIL? • Delivering late or over budget • Delivering the wrong thing • Unstable in production • Costly to maintainAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • REALITY CHECK • It is impossible to gather all the requirements at the beginning of a project. • Whatever requirements you do gather are guaranteed to change. • There will always be more to do than time and money will allow.Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • NO MORE EXCUSES • It works on my computer! • We need a satellite connection in order to • It was like that when I got run it! here! • We can’t reproduce the • The previous developer error! didn’t know XXXX! • We can’t test that!Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • WHY TDD? • Prove that your code • Regression tests as works byproduct • Avoid waste • Makechanges with (debugging) confidence • Increment code quality • Bring back the joy of coding! • Better designAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • APPLYING TDD Iteration 0 .. N Quality as a Driver Red - Green - RefactorAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • ITERATION 0 • Flush out architecture. • Setup Testing harness for TDD and BDD. • Setup continuous integration. • Setup scripts to build, deploy, etc. • Setup visual communication tools.Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • ITERATION 1.. N • Start by Story Planning • Pair programming (switching often) Every day! • Daily Scrum • End with RetrospectiveAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • QUALITY AS A DRIVER Red BDD Red Refactor Refactor TDD Green GreenAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • RED •Write a test that fails •Relax, is ok if it compilesAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • GREEN • Try to make the test pass • Do a simple solution • Use default values (not throwing exceptions) • Don’t worry if the code “smells”Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • REFACTOR • Avoid repeating code • Avoid hardcoding dependencies • Avoid “write only” code • Refactor with confidence! • Run all tests if possibleAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • DEMO Unit Testing Frameworks Given - When - Then Listing Contents ReviewsAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • TESTING FRAMEWORKS • MsTest, xUnit, nUnit, MbUnit, MSpec • Similar “hooks” • Before and after test • Before and after all test • Arrange, Act, AssertAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • GIVEN WHEN THEN • Test one “scenario” at a time • Clear identification of functionality • Easy to write, understand and maintain • Repeatable, easy to learn Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • LISTING CONTENTS • Controller “Movies” method “Index” • Two scenarios • Given I have no movies.... • Given I have the following movies.... • Where do I get the movies from?Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • GIVEN I HAVE NO MOVIES [It] public void Should_not_return_any_movies() { var result = (ViewResult)this.ActualResult; var actual = (IEnumerable<IMovie>) result.ViewData.Model; actual.Should().Be.Empty(); } [It] public void Should_render_the_index_view() { this.ActualResult.AssertViewRendered(); }Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • GIVEN I HAVE 10 MOVIES [It] public void Should_return_all_the_movies() { var result = (ViewResult)this.ActualResult; var actual = (IEnumerable<IMovie>) result.ViewData.Model; actual.Should().Have.SameValuesAs(this._movies); }Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • ARE WE DONE? • Fail 1: IMovieLibrary is not registered in the container • Fail 2: SimpleMovieLibrary needs the db name • How can we make sure it works? • Is TDD enough?Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • FIX THE CONTAINER Component .For<IMovieLibrary>() .Instance(new SimpleMovieLibrary(dbFile))...Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • SAFETY NET Scenario: Browse available movies Given I have the following movies: | title | | Blazing Saddles | | Space Balls | When I go to "Movies" Then I should see in the listing: | title | | Blazing Saddles | | Space Balls |Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • SUMMARY Benefits Challenges AdoptionAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • BENEFITS • Let the methodology drive • It will save your bacon! • High quality the whole way! • Very few bugs! • Do your duty as developer!Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • CHALLENGES • Very different from conventional testing • Many developers find it complex to learn at first • Hard to start without a Mentor • Management buy in • Difficult to keep under deadline pressure • Beware of code coverage!Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • ADOPTION • Find Mentor/Couch/Trainer • Small iterations • Have metrics ready (velocity, etc) • Do whatever works for you • Find out which tools will benefit you • Automate, automate, automate!Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • QUESTIONS?Amir Barylko - .NET UG Mar ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Slides: http://www.orthocoders.com/presentationsAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • RESOURCES IIAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
    • TDD TRAINING • When: May 26 & 27 • More info: http://www.maventhought.com • Goal: Learn TDD with real hands on examplesAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011