TDD- In Layman’s Terms

Whenever someone starts their professional career, one of the very new thing that comes in front of them is this word “TDD” i.e Test Driven Development. And then we start thinking on what is this TDD all about and more importantly why its being there and followed so seriously within organizations.

So , let me start with one very simple and basic question. Whenever we solve a problem, what is our first step? How do we proceed with the problem?All of us take a pen and a copy and start writing every possible solution on copy, solve the problem for all the major and edge cases and arrive to a solution.Speaking in simple terms, we are writing down our thought process on copy and arriving to a possible solution after carefully analyzing them.

This is exactly how TDD works.Whatever you are doing with a pen and a copy, you now do it with a program. You delegate all your work to program to evolve through your thought process and come to a possible solution.

It involves short development cycles in which developer writes a desired improvement or requirement that our code should pass, then produce the minimum amount of code that should pass the test and finally refactor the test to good standards.

Broadly speaking, you need to follow these steps to follow TDD:

  1. Add a test.(Any edge case you want your program to test).
  2. Run the test without any supporting logic behind the test.(In other words, test should fail).
  3. Now, update your functionailty to run the test successfully.
  4. Commit the code.
  5. Refactor the code if any refactoring is required.
  6. Commit Again
  7. Follow this cycle repeatedly.

So overall point is our code evolves through a very systematic workflow and covering all the edge cases with it.That is what any developer wants in his life, code evolution smoothly 😜.

Now the counter argument rises up against the slower development cycle that happen because of TDD. It is true that in the early phase, TDD seems slower and actually it is slower but with time and better development practice, TDD saves a lot of time, produces better design of code, allow safe and easy refactoring, increases quality and test coverage and keep us sure that our software is well tested.

So, TDD is making your life easier, making you code only what you want and more importantly making you a good programmer!!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.