DEV Community

Discussion on: Should I use Testing?

Collapse
 
sargalias profile image
Spyros Argalias

Welcome, nice to have you here :).

Well, one of the benefits of tests is that they tell you when something breaks. Ask yourself: when you write code, do some things break? When things break, do you immediately find out what broke and how? Or do things break which you don't notice for a while?

Tests help you because they show you what broke immediately. Then you can revert your code or fix it right away. If you think that will be helpful, then write tests, otherwise there isn't much point.

In addition, tests save you time... I'm assuming that after you code something, you spend a couple of minutes going on the browser and checking that things are working correctly. Automated tests can do that for you much faster.

In my experience, all projects benefit from testing, even if they're added late in development.

But finally, as a counter-argument, tests are difficult to get right. If you don't write them well they can actually make your project worse. Bad tests are a maintenance nightmare. They take a long time to write. They also take a long time to modify if you make changes to the code they're testing.

So overall, my personal recommendation is:

  • start learning how to test. If you're a complete beginner at testing, I recommend starting with a course.
  • if your project is a serious project that you want to release soon, don't worry too much about testing. Instead, add some tests after you learn the basics. Don't force yourself to add tests right away.
  • if you're using your project for practice and to improve your programming skills, then feel free to start writing tests immediately. It's all good practice.

Hope that helps. Let me know if anything didn't make sense or if I should explain something better.

Collapse
 
glitchcodes profile image
Vincent Tampos

Yeah, I'm the guy that tests the website right after I made changes in the code and I really liked that you shared your experience in counter-argument. Thank you! I'll look into cypress or jest as my starting point.