Why we do Test Driven Development?

Under the TDD (Test Drive Development) principles we create the test case scenario for a unit of code, BEFORE we actually write the code for the UNIT, this might seems backwards at first, but it actually makes sense, because in the real word this is how it works.

Let me explain what I mean for in the REAL WORLD, here is an example.



In the previous video, there is a function that the robot need to perform, and a series of challenges (Test) that need to be accomplished in order to wing the prize.

  • Get the robot to the Moon
  • Find Ice
  • Survive 1 Moon night = ¬†2 Earth weeks of really cold temperatures
  • Find ¬†artifacts of previous explorations

This challenges (Test) are created by mother nature, and the engineers know that the product that they will design need to pass those test, or in other words, the engineers did not create a robot and then see what it can do, they know what should be the results and performance of the robot, in the physical world of matter where we live.

In the previous example, the test (Expected Functionality) already exist, and let me give you an example, the Moon already exist is there, the robot just needs to get there, so the engineers just need to create the robot and spaceship that will get there, the test was created by mother nature millions of years ago.

is not like, look we create a robot, now lest create a moon and see if it can get there, the moon (the test) existed before the robot was created.


In the Digital world, the one of 0’s and 1’s, there we are creating that one as we go, and for that reason we need to create the tests before we create the code.

this is one of many reasons why we do the TDD

Here is an article that explain other reasons why we should use TDD. LINK


Copyright 2017. All rights reserved.

Posted December 21, 2017 by Edmundo in category "TDD