The old-school approach to programming is DDT (Development-driven testing). It means that you code first and then test the code. However, nowadays, in the Agile reality, more and more companies are turning to the opposite development process due its substantial and tangible benefits.
TDD is a software development process which is based on the iteration of a very short development lifecycle. First developers create automated test case. Initially, it is failing and is marked red, then they write the code intended to pass the test. If the test is successful, it is marked green. And finally developers refactor the code improving its non-functional attributes, making it more readable, maintainable, and less complex.
Changing the direction from development-based testing to testing -based development results in the different approach. TDD drives profound transformations in the development lifecycle changing the way developers think and approach the very phenomenon of coding .Efficacious TDD implementation urges developers and testers to delve more deeply into the requirements and how the system is supposed to work. Developers can cover them through user stories and use cases.
The benefits it offers are:
- More extensive and comprehensive test coverageSince the development in TDD is executed piece by piece, there is more confidence that every element of the code is tested and modified complying the requirements.When a change is introduced, all is needed is to run already written test cases without any need to change database management systems or the development process itself.
- Minimum of bugsFull test coverage results in decreasing the number of bugs to minimum. In development and testing processes, the more bugs are detected, the more are to be introduced later. So the key to high-class quality is to have as few bugs as possible, in the first place.
- Reduced time and costsThe less bugs you have, the less cost and time you need to fix them. In addition, the development feedback time is reduced.
- Increased confidenceSince programmers know that quality won’t be challenged, they are more confident to add new functionality and change architecture of an application.
Additional bonuses are:
- Better API interfacesSince in TDD use cases go first, developers look at API from the perspective of the user.
- More economical and maintainable code due its effective refactoring.