1 / 12

Introduction to Test Driven Development

Introduction to Test Driven Development. What is TDD?. It is an iterative development technique Focused on design rather than validation Also referred as: Test first development. TDD effects. Improve and speed up software development Have flexible and extensible code

osias
Download Presentation

Introduction to Test Driven Development

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to TestDrivenDevelopment

  2. What is TDD? • It is an iterativedevelopmenttechnique • Focused on design ratherthanvalidation • Alsoreferred as: Testfirstdevelopment

  3. TDD effects • Improve and speedup software development • Haveflexible and extensiblecode • Reducebugs • Improvedocumentation

  4. TDD mantra • Write testbeforeimplementation • Refactor, refactor, refactor • Relies on unittesting and unittestingframeworks • ”Unittestsrunfast, iftheydonotrunfasttheyarenotunittests”

  5. TDD: step 1 • Think in terms of baby steps • Focus on the behaviouryouwishyourcodewillhave THINK

  6. TDD: step 2 • Write a test, watchitfail • Focus on the behaviouryourclass and methodwillhave • A.K.A. nameyour API properly THINK FAIL

  7. TDD: step 3 • Write the code, makeitpass • Write the minimalamount of codethatmakes the testpass THINK FAIL PASS

  8. TDD: step 4 • Simplify and improve the design • Do NOT modify the behaviour! THINK FAIL PASS REFACTOR

  9. TDD cycle THINK FAIL PASS REFACTOR

  10. Limitations • Steeplearningcurve • Itrequiresdiscipline to conform to the process • Hard to apply to GUI development • Hard to apply to legacycode

  11. References • Kent Beck: Testdrivendevelopmentbyexample • Dave Astels: Testdrivendevelopment, a practivalguide

  12. Exercise For this exercise you will implement as simplified version of a tennis game using Test-driven development: • A game is won by the first player to have won at least four points in total and at least two points more than the opponent. • The running score of each game is described in a manner peculiar to tennis: scores from zero to three points are described as "love", "fifteen", "thirty", and "forty" respectively. • If at least three points have been scored by each player, and the scores are equal, the score is "deuce". • If at least three points have been scored by each side and a player has one more point than his opponent, the score of the game is "advantage" for the player in the lead.

More Related