In his book Working Effectively with Legacy Code, Michael Feathers defines legacy code as:
“Legacy code is code without tests”
What I like about this sentence is that illustrates the importance of tests in Software Development.
There are different ways to look at tests: in most cases, tests act as a safety net, supporting engineers to catch unwanted changes in the code. But tests can be much more than this, and can be used as a framework to write better software as well, helping engineers to design better APIs, or even used as documentation, supporting newcomers to understand the expected behavior and design decisions.
When writing tests, engineers might take different strategies. Some prefer to write them after the implementation is finish, while others prefer to write tests before, for instance in Test-Driven Development (TDD), or Behavior-Driven Development (BDD). But the truth is, these different approaches don’t diminish the importance of having a good test coverage and testable code.