You can use “unit tests” without going completely in a TDD process.
I try to have a pragmatic approach in my job or for personnal projects that is the following:
- Wrote unit test during the developpement process for parts that i found critical of difficult.
Critical because i haven’t the right to introduce a bug
Difficult because i will have difficulty to enhance theses parts without taking some risks to break something.
In this stage, i not write a billions of unit tests and i try to keep reasonnable.
After this developpement process, become the maintenance time when a bug is found.
When a bug is found in production, i consider we never see it in all stages we can have (dev, internal test, client test)
So it’s not a “simple bug”, and in this case, we wrote a unit test that can check this precise bug that protect us to have it again.
With this approach, i can reduce costs of unit tests (in term of time and effort) and trying to maximize theses benefits.
Best regards,
Séb.