nanyang-system-developers

Test-Driven Development (TDD)

Overview

Test-driven development (TDD) is a software development process characterized by the practice of writing tests prior to writing the actual code. TDD follows a repeated cycle and relies heavily on automated testing.

TDD Cycle

The cycle commonly associated with TDD consists of three distinct steps:

  1. Write a Test: Start by writing a test for the new function. This test is initially expected to fail, ensuring that the new code is necessary and that the test is effective.

  2. Write Code: Write the minimum amount of code required to pass the test. This step often leads to simplified and efficient coding.

  3. Refactor: Once the test is passed, refactor the code for improvement, ensuring that it remains efficient, clean, and adheres to coding standards. Repeat the cycle for new functionalities.

Benefits of TDD

Further reading