While this answer is not historically accurate — unit testing precedes the Agile movement — it’s clear that the Agile exponents made it a widespread practice. In large part, because of Kent Beck’s lapidary JUnit implementation, which has been widely copied to most major languages.
The specific benefit Andrew — and many other developers — have enjoyed is quite simply less time spent in the debugger. Today he writes code and then he writes unit tests that exercise the edge cases and one or two main cases. Right away, Andrew can tell if he missed something obvious or if his implementation has a slight burble that mishandles cases he expected to flow through easily.
Read the rest of this artcile here.