Shrijana's Blog

CSIT Student > Blogger > Web Developer

Follow me on GitHub

Test Driven Development(TDD)

Test Driven Development is also called Test Driven Design. It is a software development discipline where developer write automatic test cases for enhancement or new feature before they write any code. It begin by writing a failing test for the simplest piece of functionality that you need to implement then write a simplest code which makes to pass that test. Once this is done the new code is re-run or re-factored(reworking of code). It relies on the repetition of a very short development cycle:

  1. Writing failing tests(Red)
  2. Write code that makes the test pass(Green)
  3. Re-factor the code.(Refactor)

Why TDD?

A significant advantage of TDD is that it enables you to take small steps when writing software. In my experience it is far more productive than attempting to code in large steps. You can have immediate feedback on if your code is working, so you can find bugs faster. And, most importantly, you can see the test go from failing to passing, it will build your confidence level also. By writing tests first, you have an outline of what you want the code to do before you start writing it.

Benefits of TDD

  • It helps to ensure quality by focusing on requirement before wring a code.
  • It keeps code clear, simple and testable
  • it provides documentation about how the system work.
  • It provides repeatable tests
  • It enables rapid change