Although having a regression suite is certainly a compelling benefit of testing, testing, in my opinion, pertains to more than detecting regressions.
Writing tests:
Writing tests:
- gives you immediate feedback about the quality of your design ideas;
- encourages you towards code that is both loosely coupled and highly cohesive;
- adds an executable specification of the what the code should do; and,
- lets you know when you've done enough, discouraging gold plating and from adding functionality until deemed necessary (because YAGNI!).
