A set of tests can help when:
- Debugging
- Refactoring
A set of tests can prevent a bug making it out of a development environment, whether as the result of a change, or because the feature is new.
Refactoring, or restructuring, existing code has a high chance of introducing bugs. If a script or function already has tests, the risk is reduced. Tests that verify overall functionality (not necessarily unit tests) should continue to pass after refactoring.