Faysal Ahamed

Full-stack Web Developer

Why spending time on writing tests for software?

by Faysal Ahamed · #testing #phpunit

I have been developing web-based software using PHP for more than 5 years. I never wrote any test or did not know how to write before I started writing tests for my Laravel applications from early 2019. I become familiar with the term TDD (Test Driven Development) when I started learning Ruby On Rails before my PHP journey. But I felt boring writing tests. At some point, I felt it easier to write code and develop web applications quickly in PHP and my PHP journey began.

I developed many web applications without automated testing and had to spend hours to check if all functionalities working correctly. In late 2018, I started following Laravel community peoples and contributors on Twitter. I found they talk about tests a lot and I was interested in testing. I started learning about testing from Laracasts and started writing tests in Laravel based applications. This time I found it interesting and beneficial. Even without looking at the browser, I can confidently tell my code is working.

The biggest benefit I get when refactoring or making any changes after a few months. I never felt confident to change any code in my application before writing tests.

It is true that writing tests will require some extra time, but I can guarantee that spending time for writing tests is worthy. Frameworks like Laravel, Ruby on Rails, etc has very nice testing features. Currently, I am using Laravel most of the time and it has very good wrappers around PHPUnit and it makes easy to write tests.

Here are some bullet points-

  • No need to run the application manually to check the functionality.
  • Easy to refactor or make any change after long time.
  • Easy to upgrade language version or framework version or any package.
  • Other developer (who know TDD) will feel feel comfortable to contribute
  • Easy to maintain for longer period.
  • There are many things...