TDD : Test Driven Development

HarshaVardhanReddy Bommareddy
2 min readAug 28, 2020

Hello!
Hope everyone is well and staying safe.

I would like to share about few points about Test Driven Development (TDD).

Test Driven Development is a software development process where testing is used to develop in small cycles.

First write test cases and then the production code. This seems a little difficult initially but following this process increases the quality of production code.

The TDD Cycle
  • Write a test and make it fail
  • Write enough code to make the test pass
  • Refactor the code. If there is nothing to refactor skip this step, but when we write complex code we do have to write enough tests to pass while maintaining the code readability and making sure all the test cases are passed.

Why TDD?

  • TDD improves the quality of code and reduces a lot of issues raised during the testing phase.
  • Writing tests first makes sure more bugs are fixed before production.
  • TDD leads to 40%-80% fewer bugs in production.
  • TDD eliminates fear of merging the code.

Conclusion

TDD is always a way to write better code and reduces bug before production. It feels like we are spending a lot of time in writing tests which is extra time but if we don’t we will be doing the same for debugging and fixing the bugs.

Hope this will be helpful.
Thanks!

--

--