Do I need tests?

Do I need tests? People working in the industry will often say, "yes! what a dumb question!"

And if you then ask "why?" you will get all kinds of answers. People will tell you that you need tests because:

  • it's a requirement
  • tests are important
  • you are paid to write them
  • the boss told us to have tests

None of those answers make sense to me; because none of them explain why I need tests.

There's nothing mysterious about having tests. The only reason you need tests is that they can help you. That's it. Help with what exactly? Easy. They should help you to:

  • confirm that your code works as you think it works
  • refactor existing code
  • find regressions right away when production code changes
  • reduce maintenance of existing production code

Unfortunately, it's not a common approach in the industry that tests are something that helps. If they don't help you, feel free to throw them away. And write the ones that help. Because you still need them.

Of course, it takes some time to understand how to write such tests. We'll talk more about that.