Test-driven Development – A Software Development Process

What is Test-driven Development?

Test-driven development is a process or technique for the development of software or code. The main focus with this process is the understanding of the requirements to enable the developer to write tests for new functionality and features before they write any code. This enables the developer to have a specific goal to work towards.

The development process contains 5 basic steps:

  1. Write a Test Case that will test a new feature or functionality.
  2. Run the Test Case
    1. The Test passes – Then either the new feature already exists in the code or the test does not test the requirement, return to Step 1
    2. The Test fails for unexpected reason – verify the Test is correct as it may not be written to properly test the feature, return to Step 1
    3. The Test fails as expected – proceed to step 3
  3. Write code
  4. Run the Test Case
    1. The Test fails – modify the code as it does not provide the necessary functionality, return to step 3
    2. The Test passes – new functionality added, proceed to step 5
  5. Refactor the code.  In this step the developer cleans up the code by removing magic numbers doing performance enhancements. By rerunning the Test Cases the developer can be assured that no bugs were introduced into the code.

This short 5 step life cycle enables the quick development of new features and functionality to an application. It also allows for regression testing of the software as new features are introduced ensuring that old functionality is not broken by any new enhancements.

What are some benefits to Test-driven Development?

Like all techniques the end results are dependent on the developer but some of the benefits that can be obtained by using this process are:

  • The quick development of new features as developers write code to add one feature at a time.
  • Enhanced confidence in the end product as in theory there is a Test Case for every functionality.
  • Backwards compatibility – by having a test suite for all functionality previous functionality will still be working correctly unless their Test Cases fail
  • Quick Roll Back capability – by tracking the code when each new feature is functional it allow the developer to quickly roll back to a previous state if the current code they are writing is failing to pass the Test Case.
  • Enhanced Developer confidence in themselves as the Test Cases give instant gratification that what they are writing works.

Comments & Questions

Add Your Comment