Test driven development(TDD) is a agile methodology technique to develop the software applications. It is one of the basic tenets of eXtreme Programming(XP).
In Test driven development life cycle unit-test cases written before the code it self. These test cases contains assertions that can be either true or false.
Unique feature of TDD is developer can focus on the requirements before writing the code. Comparative to other methodologies this is a substantial difference.
The following are the steps in the TDD lifecycle
- Add a test: In Test driven development, we will write a test case for every new feature. This test case will fail because there is no implementation for this feature through code.
- Run all tests: Make sure that every test will fail as there is no implementation for these test cases.
- Write Some Code: In this phase we can write some code that will cause the test to pass. It is important that the code written is only to pass the test not to extend the functionality.
- Run the automated tests and see them succeed: If all test cases are pass it means that the code meets all the tested requirements.Now we can begin the final step of the life cycle.
- Refactor code: Code cleanup activities can be performed now. By re-running the test cases developer can be confident that refactoring is not damaging any existing functionality.
- Test driven development (TDD) can help to build software better and faster
- It allows the programmer to focus on the task to make the test case pass.
- It ensures that all written code is covered by test and this can give the programmer a greater level of trust in the code.
- Large number of test cases help to limit the number of defects in the code.
In the next article i am going to explain about TDD using C#.