Test Driven Development

Profile picture for user devraj

Test-driven development (TDD) is an evolutionary approach to development that combines test-first development where we write a test before we write code.

This approach converts software requirements to test cases before the software is fully developed and tracks all software development by continually Testing the software against all test cases. It is the opposite of the conventional approach where first we develop software and later Test it.

Why Test Driven Development

  1. Flexible and Extensive Code: You can define TDD as a programming practice instructing developers to write new code only if an automated test has failed. It avoids duplication of code. 
  2. Prevent Bugs: The primary goal of TDD is to make the code clearer, bug-free and straightforward. 
  3. Iterative: TDD relies on a concise development cycle. Once all the tests pass, it signals the end of the iteration. For implementing more features in your product, the product will go through the same phases again, but this time with the new feature set and more tests.
  4. Specification First: The goal of TDD is a specification, not validation.
  5. Agile Requirement: TDD is related to the test-first programming concept of extreme programming. TDD is both an essential agile requirement and an agile design technique. TDD enhances collaboration between development, QA teams, and client. Test-driven development refers to a style of programming in which three activities are tightly interwoven: coding, Testing, and Design.
  6. Unit Testing: Unit Testing is integrated into TDD practice; TDD ensures that the source code is thoroughly unit tested and leads to modularised, flexible, and extensible code.
  7. Test Coverage: We try to achieve 100% Test Coverage in TDD by ensuring every single line of code is tested, unlike conventional testing.