Content deleted Content added
Reverted 1 edit by Xcelligen Inc (talk): Spam |
Stevebroshar (talk | contribs) TDD is not about requirements; it's a series of steps for coding |
||
Line 1:
{{short description|
{{Software development process}}
'''Test-driven development''' ('''TDD''')
Alternative approaches to writing automated tests is to write all of the production code before starting on the test code or to write all of the test code before starting on the production code. With TDD, both are written together.
Test-driven development is related to the test-first programming concepts of [[extreme programming]], begun in 1999,<ref name="Cworld92">{{cite web |url=http://www.computerworld.com/softwaretopics/software/appdev/story/0,10801,66192,00.html |title=Extreme Programming |author=Lee Copeland |date=December 2001 |publisher=Computerworld |access-date=January 11, 2011 |archive-url=https://web.archive.org/web/20110605060209/http://www.computerworld.com/s/article/66192/Extreme_Programming?taxonomyId=063 |archive-date=June 5, 2011 |url-status=dead }}</ref> but more recently has created more general interest in its own right.<ref name=Newkirk>Newkirk, JW and Vorontsov, AA. ''Test-Driven Development in Microsoft .NET'', Microsoft Press, 2004.</ref>▼
▲
Programmers also apply the concept to improving and [[software bug|debugging]] [[legacy code]] developed with older techniques.<ref name=Feathers>Feathers, M. Working Effectively with Legacy Code, Prentice Hall, 2004</ref>
Line 23 ⟶ 25:
;1. Create a list of tests for the new feature
:
;2. Add one test from the list
:Write an automated test that passes if the variant in the new behavior is met.
;3. Run all tests. The new test
:This shows that new code is actually needed for the desired feature. It validates that the [[test harness]] is working correctly. It rules out the possibility that the new test is flawed and will always pass.
;4. Write the simplest code that passes the new test
Line 40 ⟶ 42:
:** splitting methods into smaller pieces
:** re-arranging [[Inheritance (object-oriented programming)|inheritance hierarchies]]
:Repeat the process with each test on the list until all tests are implemented and passing.▼
;Repeat
▲:Repeat the process, starting at step 2, with each test on the list until all tests are implemented and passing.
:The cycle above is repeated for each new piece of functionality. Tests should be small and incremental, and commits made often. That way, if new code fails some tests, the programmer can simply [[undo]] or revert rather than [[debug]] excessively. When using [[Library (computing)|external libraries]], it is important not to write tests that are so small as to effectively test merely the library itself,<ref name=Newkirk /> unless there is some reason to believe that the library is buggy or not feature-rich enough to serve all the needs of the software under development.
|