Test Driven Development (TDD)

Test Driven Development is the process in which test cases are written before the code that validates those cases. It depends on repetition of a very short development cycle. Test driven Development is a technique in which automated Unit test are used to drive the design and free decoupling of dependencies.

The following sequence of steps is generally followed:

  1. Add a test – Write a test case that describe the function completely. In order to make the test cases the developer must understand the features and requirements using user stories and use cases.
  2. Run all the test cases and make sure that the new test case fails.
  3. Write the code that passes the test case
  4. Run the test cases
  5. Refactor code – This is done to remove duplication of code.
  6. Repeat the above mentioned steps again and again

Motto of TDD:

  1. Red – Create a test case and make it fail
  2. Green – Make the test case pass by any means.
  3. Refactor – Change the code to remove duplicate/redundancy.

Benefits:

  • Unit test provides constant feedback about the functions.
  • Quality of design increases which further helps in proper maintenance.
  • Test driven development act as a safety net against the bugs.
  • TDD ensures that your application actually meets requirements defined for it.
  • TDD have very short development lifecycle.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.