“Unit testing” is writing many small tests that each test one very simple function or object behavior. TDD is a thinking process that results in unit tests, and “thinking in tests” tends to result in more fine-grained and comprehensive testing, and an easier-to-extend software design.Please keep the questions coming! It’s a great way to keep this newsletter timely and helpful.
TDD is not a technology, it is an approach. That will guide you to write more cleaner and understandable codes.
In TDD,
- First of all, we need to understand what are the user requirements clearly.
- Then we write a test to fail. It's indicated as RED status.
- One test case is failed. We write codes to pass that test case it's indicated as GREEN.
- Then we can refactor that written code. You can follow SOLID principles in this step.
- And again run that test case and verify that refactored code against the test case.
- The intention of your code is clear, It means you have understood the requirements as well.
- Iterative development and testing.
- Catching defects early.
- You are forces to write test cases.
- Documentation.
- Defects can catch very easily even it occurred in the production.