Why automated testing is important

Automated testing is the practice of writing test code to evaluate code that performs application logic. Whenever we write any program, even one as simple as "Hello, World!", we run it and check for ourselves that it indeed does what we want it to do. Automated testing is the process of automating this 'check for ourselves' process, especially for applications that to do far more than print "Hello, World!".

Why do this you may ask? Why write MORE code that delivers an equal amount of output to the end user? Testing shows its true benefits for applications that are complex and developed in a team setting. Here are the main reasons why testing is so important:

Ensures that the shiny new feature does not break the trusty old one

It spells peace of mind for both you and your team when you run a test suite and it comes back green. It means you haven't broken anything, the code works and it works as expected. If a feature has been developed by someone else, you may not be aware of all the edge cases and complex scenarios that they had to take into account. A good test suite is aware of that and makes your change reliable.

Net time-saver over long run

A good test suite takes time to write. But it starts saving time for your QA process everytime you dont have to manually run to all the regression cases. The saved time builds up, while the time spent is static. It's like an investment, after a certain point in future it starts more than paying for itself.

Forces good coding practices

Spaghetti code is difficult to write unit tests for. High level of coupling and long reaching dependencies are difficult to mock for. Writing tests forces you to improve the code, making it modular, mockable and follow single responsibility.

Documentation

There's a statement which I don't 100% agree with, but there is quite a bit of truth to it:

"Comments are a decaying form of documentation."

You cannot guarantee that tomorrow if you or someone else changes behavior of code, they will change the relevant comment too. This out-of-sync behavior may cause huge confusion for someone further down the timeline. Tests, though, are code. If you want to maintain the green color output, you have to change the tests. This ensures a sync between feature and tests far better than a sync in feature and comments.

Combined together, these benefits far outweigh the initial time and effort expended on writing tests. On an application of large complexity, under development by multiple people, tests will save a lot of pain down the line.