April 15, 2013
Rather than following the conventional method of application development by following the flow -> requirements study, analysis, design, development, implement, test and bug fixing, TDD uses a slightly varied methodology.
The series of steps in TDD to be followed by a developer are:
Change the code to implement the new functionality.
Run the test case again, result should be PASS.
Run a regression suite to uncover any regression defects. (This step can be carried out before every release or at reasonable periodic intervals.)
The most important condition for TDD to be a success is correct understanding of a requirement by the developer. If the developer misunderstands a requirement, the test script and consequently the code will be wrong.
There have been discussions on whether and how TDD can prove beneficial when applied to the software industry. Right from improving a developer’s confidence to defect reduction, when adopted appropriately, TDD can help handle complicated software development challenges.
Requirements Coverage – The developer writes a test case to test each feature so there is one-to-one mapping which helps the developer ensure that no features are left out.
Structured Design – When the developer begins by writing a test case, the focus in on how the end user uses the feature and the kind of interface that must be provided. It is not just about fulfilling the functional requirement.
Defect Reduction – The developer can instantly catch a bug once the new code is added to the code base. Bug fixing is considerably easy as the source is isolated and known. Also, regression bugs can be reduced to a large extent thus enabling a smooth integration of new code with the existing one.
Early time-to market – Since the developers test and fix the code almost instantly, the overall application development time is reduced. Furthermore, this approach eliminates the chance of a major code break, (when multiple developers are working) thus encouraging developers to make code changes at a faster pace.
Futuristic Use – The test scripts created by developers are exhaustive and focused and can be used for regression testing later in the project lifecycle.
Developer’s confidence – Once the practice of test-first-code-then sets in, developers get a better understanding of what is needed, consequently helping them code better and with confidence.
There have been studies and researches to find out whether TDD actually helps in defect reduction, and it can be safely said yes, it does. However, depending upon the nature of the application and frequency of changing requirements, other methods such as code inspection can prove more effective in defect reduction.
The cost of investment and benefits of these methods must be studied with respect to a project to understand the best defect-reduction technique. In some projects, a combination of different methods can be implemented to improvise software quality.