Test Driven Development (TDD) is a software development practice that focuses on creating unit test cases before developing the actual code.
It is an iterative approach that combines programming, the creation of unit tests, and refactoring.
This is as opposed to software being developed first and test cases created later.
- write a “single” unit test describing an aspect of the program
- run the test, which should fail because the program lacks that feature
- write “just enough” code, the simplest possible, to make the test pass
- “refactor” the code until it conforms to the simplicity criteria
- repeat, “accumulating” unit tests over time
Advantages of TDD:
- You only write code that’s needed
- More modular design
- Easier to maintain
- Easier to refactor
- High test coverage
- Tests document the code
- Less debugging
- Developer can consider it as a waste of time.
- The test can be targeted on verification of classes and methods and not on what the code really should do.
- Test become part of the maintenance overhead of a project.
- Rewrite the test when requirements change.
Comments
Post a Comment