Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Test-driven development
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Benefits === A 2005 study found that using TDD meant writing more tests and, in turn, programmers who wrote more tests tended to be more productive.<ref>{{cite web | url = http://nparc.cisti-icist.nrc-cnrc.gc.ca/npsi/ctrl?action=shwart&index=an&req=5763742&lang=en | title = On the Effectiveness of Test-first Approach to Programming | access-date = 2008-01-14 | last = Erdogmus | first = Hakan | author2 = Morisio, Torchiano | publisher = Proceedings of the IEEE Transactions on Software Engineering, 31(1). January 2005. (NRC 47445) | quote = We found that test-first students on average wrote more tests and, in turn, students who wrote more tests tended to be more productive. | archive-url = https://web.archive.org/web/20141222180731/http://nparc.cisti-icist.nrc-cnrc.gc.ca/npsi/ctrl?action=shwart&index=an&req=5763742&lang=en | archive-date = 2014-12-22 | url-status = dead }}</ref> Hypotheses relating to code quality and a more direct correlation between TDD and productivity were inconclusive.<ref>{{cite web | url = http://theruntime.com/blogs/jacob/archive/2008/01/22/tdd-proven-effective-or-is-it.aspx | title = TDD Proven Effective! Or is it? | access-date = 2008-02-21 | last = Proffitt | first = Jacob | quote = So TDD's relationship to quality is problematic at best. Its relationship to productivity is more interesting. I hope there's a follow-up study because the productivity numbers simply don't add up very well to me. There is an undeniable correlation between productivity and the number of tests, but that correlation is actually stronger in the non-TDD group (which had a single [[outlier]] compared to roughly half of the TDD group being outside the 95% band). | archive-url = https://web.archive.org/web/20080206103552/http://theruntime.com/blogs/jacob/archive/2008/01/22/tdd-proven-effective-or-is-it.aspx | archive-date = 2008-02-06 | url-status = dead }}</ref> Programmers using pure TDD on new ("[[Greenfield project|greenfield]]") projects reported they only rarely felt the need to invoke a [[debugger]]. Used in conjunction with a [[version control system]], when tests fail unexpectedly, reverting the code to the last version that passed all tests may often be more productive than debugging.<ref>{{cite web | url = http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-1 | title = Stepping Through the Looking Glass: Test-Driven Game Development (Part 1) | access-date = 2007-11-01 | last = Llopis | first = Noel | date = 20 February 2005 | publisher = Games from Within | quote = Comparing [TDD] to the non-test-driven development approach, you're replacing all the mental checking and debugger stepping with code that verifies that your program does exactly what you intended it to do. }}</ref> Test-driven development offers more than just simple validation of correctness, but can also drive the design of a program.<ref>{{cite book|last1=Mayr|first1=Herwig|title=Projekt Engineering Ingenieurmässige Softwareentwicklung in Projektgruppen|date=2005|publisher=Fachbuchverl. Leipzig im Carl-Hanser-Verl.|location=München|isbn=978-3446400702|page=239|edition=2., neu bearb. Aufl.}}</ref> By focusing on the test cases first, one must imagine how the functionality is used by clients (in the first case, the test cases). So, the programmer is concerned with the interface before the implementation. This benefit is complementary to [[design by contract]] as it approaches code through test cases rather than through mathematical assertions or preconceptions. Test-driven development offers the ability to take small steps when required. It allows a programmer to focus on the task at hand as the first goal is to make the test pass. Exceptional cases and error handling are not considered initially, and tests to create these extraneous circumstances are implemented separately. Test-driven development ensures in this way that all written code is covered by at least one test. This gives the programming team, and subsequent users, a greater level of confidence in the code. While it is true that more code is required with TDD than without TDD because of the unit test code, the total code implementation time could be shorter based on a model by Müller and Padberg.<ref>{{cite web | url = https://pdfs.semanticscholar.org/65d9/24ef1162b2f3c24bd15d627302887991b298.pdf | archive-url = https://web.archive.org/web/20171108092303/https://pdfs.semanticscholar.org/65d9/24ef1162b2f3c24bd15d627302887991b298.pdf | url-status = dead | archive-date = 2017-11-08 | title = About the Return on Investment of Test-Driven Development | access-date = 2012-06-14 | last = Müller | first = Matthias M. |author2=Padberg, Frank | publisher = Universität Karlsruhe, Germany | page = 6 | s2cid = 13905442 }}</ref> Large numbers of tests help to limit the number of defects in the code. The early and frequent nature of the testing helps to catch defects early in the development cycle, preventing them from becoming endemic and expensive problems. Eliminating defects early in the process usually avoids lengthy and tedious debugging later in the project. TDD can lead to more modularized, flexible, and extensible code. This effect often comes about because the methodology requires that the developers think of the software in terms of small units that can be written and tested independently and integrated together later. This leads to smaller, more focused classes, looser [[Coupling (computer programming)|coupling]], and cleaner interfaces. The use of the [[mock object]] design pattern also contributes to the overall modularization of the code because this pattern requires that the code be written so that modules can be switched easily between mock versions for unit testing and "real" versions for deployment. Because no more code is written than necessary to pass a failing test case, automated tests tend to cover every code path. For example, for a TDD developer to add an <code>else</code> branch to an existing <code>if</code> statement, the developer would first have to write a failing test case that motivates the branch. As a result, the automated tests resulting from TDD tend to be very thorough: they detect any unexpected changes in the code's behaviour. This detects problems that can arise where a change later in the development cycle unexpectedly alters other functionality. Madeyski<ref name="Madeyski">Madeyski, L. "Test-Driven Development - An Empirical Evaluation of Agile Practice", Springer, 2010, {{ISBN|978-3-642-04287-4}}, pp. 1-245. DOI: 978-3-642-04288-1</ref> provided empirical evidence (via a series of laboratory experiments with over 200 developers) regarding the superiority of the TDD practice over the traditional Test-Last approach or testing for correctness approach, with respect to the lower coupling between objects (CBO). The mean effect size represents a medium (but close to large) effect on the basis of meta-analysis of the performed experiments which is a substantial finding. It suggests a better modularization (i.e., a more modular design), easier reuse and testing of the developed software products due to the TDD programming practice.<ref name="Madeyski" /> Madeyski also measured the effect of the TDD practice on unit tests using branch coverage (BC) and mutation score indicator (MSI),<ref>[http://madeyski.e-informatyka.pl/download/Madeyski10c.pdf The impact of Test-First programming on branch coverage and mutation score indicator of unit tests: An experiment. ] by L. Madeyski ''Information & Software Technology 52(2): 169-184 (2010)''</ref><ref>[http://madeyski.e-informatyka.pl/download/Madeyski07.pdf On the Effects of Pair Programming on Thoroughness and Fault-Finding Effectiveness of Unit Tests] by L. Madeyski ''PROFES 2007: 207-221''</ref><ref>[http://madeyski.e-informatyka.pl/download/Madeyski08.pdf Impact of pair programming on thoroughness and fault detection effectiveness of unit test suites.] by L. Madeyski ''Software Process: Improvement and Practice 13(3): 281-295 (2008)''</ref> which are indicators of the thoroughness and the fault detection effectiveness of unit tests, respectively. The effect size of TDD on branch coverage was medium in size and therefore is considered substantive effect.<ref name="Madeyski" /> These findings have been subsequently confirmed by further, smaller experimental evaluations of TDD.<ref name="Pančur">M. Pančur and M. Ciglarič, "Impact of test-driven development on productivity, code and tests: A controlled experiment", Information and Software Technology, 2011, vol. 53, no. 6, pp. 557–573, DOI: 10.1016/j.infsof.2011.02.002</ref><ref name="Fucci">D. Fucci, H. Erdogmus, B. Turhan, M. Oivo, and N. Juristo, "A dissection of the test-driven development process: does it really matter to test-first or to test-last?", IEEE Transactions on Software Engineering, 2017, vol. 43, no. 7, pp. 597–614, DOI: 10.1109/TSE.2016.2616877</ref><ref name="Tosun">A. Tosun, O. Dieste Tubio, D. Fucci, S. Vegas, B. Turhan, H. Erdogmus, A. Santos, M. Oivo, K. Toro, J. Jarvinen, and N. Juristo, "An industry experiment on the effects of test-driven development on external quality and productivity", Empirical Software Engineering, 2016, vol. 22, pp. 1–43, DOI: 10.1007/s10664-016-9490-0</ref><ref name="Papis">B. Papis, K. Grochowski, K. Subzda and K. Sijko, [https://ieeexplore.ieee.org/document/9207972 "Experimental evaluation of test-driven development with interns working on a real industrial project"], IEEE Transactions on Software Engineering, 2020, DOI: 10.1109/TSE.2020.3027522</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)