TDD stands for Test Driven Development. In this process, software requirements are changed to very specific test cases, and the software is continually improved till all tests are passed.
The steps involved are as follows:
1. Create a test: In TDD, you begin by writing a test. The tests should almost always define a function. To write a useful test, the software developer must first understand the requirements and specifications of the given project. This step must not be confused with a unit test which is done after the code has already been written. TDD allows the developer to focus on the system requirements before writing any code.
2. Run all tests and check if new tests fail: This stage ensures that the automated test framework works correctly and that new tests do not pass without needing new code, and that the new test does not always pass. The new test should not fail unexpectedly.
3. Write code: Focus on code that causes the test to pass. While the written code may not be perfect, keep in mind that the goal of the code is to pass the test. The code must not be beyond the functionality that the test checks.
4. Run test: At this stage if the test cases developed in the previous stages all passed, the programmer can be sure that the new code meets the test requirement. If the expected results were not met, the programmer must keep refactoring the code till it does.
5. Refactor, Refactor and Refactor: In TDD, refactoring is a must. New code will be moved from a convenient point from which it was tested to the place it logically belongs once the test is passed. All duplicate code must be removed to reduce ambiguity. All variables, objects, classes and method names must be clearly named to represent what they actually stand for. It may be necessary to provide some level of abstraction for your code for re-usability and maintainability purposes.
6. Repeat: Follow through the same process above for any new feature release.
Best of luck in your studies #StaySafe