Dung (Donny) Nguyen

Senior Software Engineer

Test Driven Development

Test Driven Development (TDD) is a software development approach where we write tests before writing the actual code.

TDD

Here’s a brief overview of the process:

  1. Write a Test: Start by writing a test for a new feature or functionality. This test will initially fail because the feature hasn’t been implemented yet.
  2. Run the Test: Execute the test to confirm that it fails. This step ensures that the test is valid and that the feature is not already present.
  3. Write Code: Write the minimum amount of code necessary to make the test pass.
  4. Run the Test Again: Execute the test again to see if it passes with the new code.
  5. Refactor: Clean up the code while ensuring that the test still passes. This step improves code quality without changing its behavior.
  6. Repeat: Continue this cycle for each new feature or functionality.

The main benefits of TDD include:

Reference: