What is TDD?
TDD, or Test Driven Development, is a coding approach that involves three main cycles: Red π΄, Green π’, and Refactor.
Red π΄
Create a test case that outlines the function of the code you intend to write. Start with one test case and ensure it fails, as the function hasn't been implemented yet.
Green π’
Develop the code implementation based on the test case, focusing on doing the bare minimum to make the test case pass and turn green π’.
Refactor
Refine the code that passed the test to make it cleaner and more structured, without changing its behavior.
Repeat these three steps continuously until the function is fully developed.
Is TDD mandatory?
It depends on several factors, including development time, team habits, and project goals.
Development Time: If time is limited, adopting TDD might not be wise, as it can extend the development process.
Team Habits: Developers need to be accustomed to TDD. Not all developers are used to writing test cases before implementing code.
Project Goals: If the focus is on code quality and good coverage, TDD is highly recommended.
Conclusion
TDD is highly recommended if the project needs and team dynamics support it. However, it may not be necessary in every situation.
Art
https://quii.gitbook.io/learn-go-with-tests
Top comments (0)