Because those who have been tested will not fall.
Had a fun exchange at work today. A colleague told me a thing or two about unit testing. This was covered awfully briefly during my studies, and I had read some things about it online, but a large part of my image consisted of very strong pros and cons of the practice. That’s what you get for learning from the internet, I guess.
Thing is, when you’re working on non-trivial software, you need to keep tabs on which gears are turning. Doing manual testing just won’t do, because everyone’s lazy and that’ll drain a lot of hours away. So instead, you write automated tests, taking small chunks of code and seeing whether they do what they should. This way, if anything they rely on changes and breaks existing functionality, you’ll be informed by seemingly unrelated tests that suddenly start failing.
And they’re annoying to program. Not necessarily complicated, just tedious. But that little bit of effort saves you a lot of work going back and forth between your code and the compiled product. Just hit a button and test what you’re working on, no manual setup required. Saves time, saves effort.
Not to mention testing stands side by side with compiling as a good reason to be doing other things while your computer does all the hard work.