Test-driven
development (TDD)
is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.
TDD is being quickly adopted by agile software developers for development of application source code and is even being adopted by Agile DBAs for database development.
is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.
TDD is being quickly adopted by agile software developers for development of application source code and is even being adopted by Agile DBAs for database development.
- Add
a test
- Run
all tests and see if the new one fails
- Write
some code
- Run
tests
- Refactor
code
- Repeat
Keep in mind that the idea behind TDD is to do the necessary
minimum to make the tests pass and repeat the process until the whole
functionality is implemented. At this moment we're only interested in making
sure that "the method can take 0, 1 or 2 numbers". Run all the tests
again and see them pass.
Benefits
Writing the tests first requires you to really consider what
do you want from the code.
You receive fast feedback.
TDD creates a detailed specification.
TDD reduces time spent on rework.
You spend less time in the debugger.
You are able to identify the errors and problems quickly.
No comments:
Post a Comment