Definition

test-driven development (TDD)

Test-driven development (TDD), also called test-driven design, is a method of implementing software programming that interlaces unit testing, programming and refactoring on source code.

Test-driven development was introduced as part of a larger software design paradigm known as Extreme Programming (XP), which is part of the Agile software development methodology.

Steps of the test-driven development approach

Before any new code is written, the programmer must first create a failing unit test. Then, the programmer -- or pair, or mob -- creates just enough code to satisfy that requirement. Once the test is passing, the programmer may refactor the design, making improvements without changing the behavior.

While TDD focuses on the programmer interactions at the unit level, there are other popular methods, such as acceptance-test-driven development (ATDD) or behavior-driven development (BDD), which focus on tests that can be understood by customers.

Test-driven development flow chart

These methods involve creating concrete examples as tests in collaboration between the technical staff and customer before the code is created, and then running the tests after the code is created to demonstrate the code is implemented. Having the tests known upfront improves first-time quality. ATDD and BDD require developers, testers and the business side to collaborate to imagine and discuss the software and its implications before the code is created.

Advantages of TDD

Test-driven development can produce applications of high quality in less time than is possible with older methods. Proper implementation of TDD requires the developers and testers to accurately anticipate how the application and its features will be used in the real world.

TDD creates a regression-test suite as a side effect that can minimize human manual testing, while finding problems earlier, leading to quicker fixes. The methodical nature of TDD ensures much higher coverage and first-time quality than classic phased code > test > fix > retest cycles. Because tests are conducted from the very beginning of the design cycle, time and money spent in debugging at later stages is minimized.

Disadvantages of TDD

TDD requires considerable skill to be successful, especially at the unit level. Many legacy systems are simply not created with unit testing in mind, making isolation of components in order to test impossible.

Further, many programmers lack the skills to isolate and create clean code. Everyone on the team needs to create and maintain the unit tests, or else they will quickly get out of date. And an organization looking at TDD will need to invest time -- to slow down a bit now in order to go faster later.

Finally, as with any method, the final results of TDD are only as good as the tests that have been used, the thoroughness with which they have been done and the extent to which they mimic conditions encountered by users of the final product.

This was last updated in May 2017

Continue Reading About test-driven development (TDD)

Dig Deeper on Software Testing Methodologies

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

3 comments

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

How has test-driven development changed your organization's software strategy?
Cancel
Interesting read. Article gives a precise view on how TDD works. I agree to the challenges and to overcome them I suggest Behavior-driven development (BDD) where client and developer agree upon behavior that is expected out of the application and notes are taken in simple business language. Development begins then after and it is intended to provide certain behavior rather then simply developing a functionality.
Cancel
Thank you for comments and ideas. We recently expanded this definition and included brief mentions of BDD and acceptance-test-driven development (ATDD). I am not personally convinced BDD is better than TDD or vice versa, as to me they seem like options available depending on the situations -- but I'm not a programmer! What do others out there think?

Cancel

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchMicroservices

TheServerSide.com

SearchCloudApplications

SearchAWS

SearchBusinessAnalytics

SearchFinancialApplications

SearchHealthIT

DevOpsAgenda

Close