Category: 

What Is Test-Driven Development?

Article Details
  • Written By: Mary McMahon
  • Edited By: Shereen Skola
  • Last Modified Date: 16 November 2017
  • Copyright Protected:
    2003-2017
    Conjecture Corporation
  • Print this Article

Test-Driven Development (TDD) is an approach to software design that is rooted in challenges to the production code to proceed in baby steps to build up functionality. This can feel counterintuitive to people who are just starting to learn, but it offers some advantages, including cleaner development. It can also be faster to use this method once people are accustomed to it, depending on the nature of the project. Programmers can use a wide variety of programming languages in test-driven development, and may apply it to new software, version improvements, or fixes to existing programs.

In this approach, the programmer starts by writing a test which should fail because the production code can’t execute a specific command or query. Using the failure as a basis, the programmer can develop a few lines of code to add, and run the test again. If it fails, there is something wrong that needs to be debugged before the programmer can proceed. Once it passes, the programmer is aware that the test has specifically defined and guided the creation of a function, and he or she can move on to the next function.

Ad

Instead of producing high volumes of functional code that may need to be examined later for bugs and flaws, developers move slowly and deliberately. They build up the program with extremely lean code because they’re only writing precisely what they need for specific functions. Over time, the code can grow quite large, but each line corresponds to a specific function or feature. The incidence of bugs with test-driven development should also be reduced because people effectively debug as they go by testing over and over again.

Each of the tests written can be used again at any time. The programmer may run every single one to confirm that the whole program continues to work as it should. If it doesn’t, the programmer knows that a recent line of code is a problem, and can step back to evaluate it and fix the issue. Test-driven development settings differ from a situation where someone might have to sift through numerous lines of code to find the mistake, which can eat up substantial amounts of time.

In essence, this approach involves coding for how people want software to behave, based on specific tests they administer as they move along. While test-driven development can sound time consuming and difficult, it can actually be highly efficient. Skilled developers need no more than a few minutes for each round of testing and coding. The somewhat inverse approach can also help them rethink strategies and tools to allow them to work in new and sometimes more effective ways.

Ad

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email