Your SlideShare is downloading. ×
0
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
obs-tdd-intro
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

obs-tdd-intro

323

Published on

PResentation done at

PResentation done at

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
323
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. AMIR BARYLKO TDD INTRO ONLINE BUSINESS SYSTEMS APRIL 2011Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. INTRO Why projects fail? Reality Check No more excuses Why TDD?Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. APPLYING TDD Iteration 0 .. N Quality as a Driver Red - Green - RefactorAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 11. 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
  • 12. 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
  • 13. QUALITY AS A DRIVER Red BDD Red Refactor Refactor TDD Green GreenAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 14. RED •Write a test that fails •Relax, is ok if it compilesAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 15. 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
  • 16. 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
  • 17. DEMO Unit Testing Frameworks Given - When - Then Listing Contents ReviewsAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. 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
  • 24. FIX THE CONTAINER Component .For<IMovieLibrary>() .Instance(new SimpleMovieLibrary(dbFile))...Amir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 25. 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
  • 26. SUMMARY Benefits Challenges AdoptionAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 27. 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
  • 28. 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
  • 29. 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
  • 30. QUESTIONS?Amir Barylko - .NET UG Mar ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 31. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Slides: http://www.orthocoders.com/presentationsAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 32. RESOURCES IIAmir Barylko - OBS Apr ‘11 MavenThought Inc.Wednesday, April 27, 2011
  • 33. 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

×