1.

What is TDD (test driven development)?

Answer»

TDD is defined as programming practice which starts before the development PHASE starts, unlike Traditional testing. It instructs developers to write new code only if an automated test has failed. The primary goal of TDD is to MAKE the code CLEARER, simple and bug-free.

TDD is an iterative development process. Each iteration starts with a set of tests written for a new piece of functionality. These tests are supposed to fail during the start of iteration as there will be no application code corresponding to the tests. In the next phase of the iteration, Application code is written with an intention to pass all the tests written EARLIER in the iteration. Once the application code is ready tests are run.

Any failures in the test run are marked and more Application code is written/re-factored to make these tests pass. Once application code is added/re-factored the tests are run again. This cycle keeps on happening until all the tests pass. Once all the tests pass, we can be sure that all the FEATURES for which tests were written have been developed.

Following steps define how to perform TDD test

  • Add a test.
  • Run all tests and see if any new test fails.
  • Write some code.
  • Run tests and Refactor code.
  • Repeat.

Benefits of TDD

  • The unit test proves that the code actually works
  • Can drive the design of the program
  • Refactoring allows improving the design of the code
  • Low-Level regression test suite
  • Test first reduce the cost of the bugs



Discussion

No Comment Found