Interested how Laravel works under the hood? → Check my Laravel Core Adventures Course

3 Compelling Reasons For Developers To Write Tests

#testing #laravel

Testing is a critical part of the development process. Here are 3 reasons why developers should make it a priority: confidence, maintainability, and time.

When you start thinking about writing tests for your applications, HOW to do that is what you mainly begin with. Fair enough, you need to learn available tools and techniques. I've also written an article about that called Everything you can test in a Laravel application.

But what drives you to start (and keep) writing tests is understanding WHY you are doing it. The reasons behind it will help you see the benefits and motivate you. This is what I want to talk about in this article. I will give you my top reasons for writing tests and why I think you should do that too.

Confidence

The main reason why I started writing tests is to gain confidence, not in myself, but in my code. It's not like I didn't trust my code, but tests make a big difference. I know it works, and I know it will continue to work.

Also, I'm not writing code just for myself. There will always be end-users or clients interacting with what I have built, and I want to ensure they can do that without any problems.

Having tests make me feel good about my work, and I can let it out into the wild without worrying too much. I know I have done my best to limit possible bugs and errors. And if bugs still occur (what can happen), there is a good starting point to fix them.

Maintainability

By writing tests, you are already investing in the future of your application. Covering your code with tests is extra work today but will pay off many times later. You will be able to:

  • refactor your code
  • add new features
  • or update your dependencies

Every change to a working application can be scary. You never know what you might break. But with tests, you can be sure you will at least see if you broke something. Your tests will tell you!

Tests also help you if you return to an old project or join a different one. You can quickly see what the application does and how it is supposed to work. This is a massive benefit for you and your team. That's why developers also say that tests are a form of documentation.

Time

I know writing tests takes time, especially at the beginning. That's why many developers do not write them. They have a strict deadline and need to get things done. I've been there, too, it's not easy, but this is a short-term view. If you work on a project for a more extended period, you will see that you will even save time by writing tests.

This is also something that you can tell your boss or team lead. Writing tests will save you money in the long run; a lot of money.

This is because you will:

  • have fewer bugs and errors from the beginning
  • be able to fix bugs faster (without side effects)
  • be faster when updating your application or adding new features

I'd say any project that should be used for more than some months tests will save you time and money. Again, writing tests is an investment in the future of the application. It shows that you are serious about this project.

Note: The more you are familiar with testing, the faster you will get writing them as well.

Conclusion

It is not easy to get into testing, and it might take some time to get used to it. What helped me was learning why I write them and how I benefit from doing so. Today, I couldn't work without them anymore.

If you want to learn more about testing, I do have a few resources of mine for you:

Do you enjoy my posts?

Sign up for my newsletter to receive updates on my latest content.

You will receive monthly updates on my latest articles and products. I do care about the protection of your data. Read my Privacy Policy.