Why is testing important? — Transcript

Transcript of the free Vue.js lesson Why is testing important?watch the video lesson.

Convincing someone who never wrote a test before of the importance of testing is hard. Believe me, I've been there. Today I'm someone who takes a hard stance against anyone not testing that code. How come?

So I'll try to explain why testing is such an important tool in any software developer's skillset. First, confidence in your code. Testing gives you confidence in your code. Writing a test is not a sign of weakness or implies that the code underneath is bad.

But as we continue in working on our code, we can say with confidence that everything still works the way that it should. Also, it's documentation for developers. Writing a test can also be treated as documentation of your code. After a few weeks not touching a certain part of your codebase and then returning to it, it's great to check out the tests and verify what the expected outcome of specific code should actually be.

I know for sure it always helps me reminding myself. Third, refactoring gets easy. As mentioned before, a task gives us confidence in not accidentally breaking working code. One thing developers love besides creating new code is refactoring code.

This means revisiting and updating some code. The reasons for refactoring can be many like leveraging the shiny new function you just learned about, improving performance, you want to extend behavior, or just simplify code that we wrote some time ago, actually. Refactoring can always bear the risk of accidentally altering the outcome of a function. So if we have an automated test that tells me the results are still the same as before, we made a great job in updating our code without breaking anything.

Four, you can become a better developer. This maybe sounds strange. The writing test for code we just created would make us better developers. But if you are a little as me in the beginning, you'll sometimes look at functions and have no idea how to test them.

A test should be simple and not longer or even more complex than the function it's supposed to test. In that case, the best way forward is to simplify the tested function. Maybe split up some code and so on. As a result of running through this process over and over again, I learned to write better and more focused code.

that actually aims for being simple to test. The last point is working in a team. Eventually, a lot of code written gets seen by other people. If you're coding on your next big startup with your friends, you don't want to break code by accident.

You do not want your users to experience an app in a broken state, and you don't want colleagues to break your code either. Writing tests when working in a team is the most important tool you have to succeed and progress your application. by avoiding to fix broken things over and over again. Think of any large open source project that you might be using.

I guarantee you that every successful project is backed by quality tests written to ensure the stability of the software. Convincing someone who never wrote a test before of the importance of testing is hard. Believe me, I've been there. Today I'm someone who takes a hard stance against anyone not testing that code.

How come? So I'll try to explain why testing is such an important tool in any software developer's skillset. First, confidence in your code. Testing gives you confidence in your code.

Writing a test is not a sign of weakness or implies that the code underneath is bad. But as we continue in working on our code, we can say with confidence that everything still works the way that it should. Also, it's documentation for developers. Writing a test can also be treated as documentation of your code.

After a few weeks not touching a certain part of your codebase and then returning to it, it's great to check out the tests and verify what the expected outcome of specific code should actually be. I know for sure it always helps me reminding myself. Third, refactoring gets easy. As mentioned before, a task gives us confidence in not accidentally breaking working code.

One thing developers love besides creating new code is refactoring code. This means revisiting and updating some code. The reasons for refactoring can be many like leveraging the shiny new function you just learned about, improving performance, you want to extend behavior, or just simplify code that we wrote some time ago, actually. Refactoring can always bear the risk of accidentally altering the outcome of a function.

So if we have an automated test that tells me the results are still the same as before, we made a great job in updating our code without breaking anything. Four, you can become a better developer. This maybe sounds strange. The writing test for code we just created would make us better developers.

But if you are a little as me in the beginning, you'll sometimes look at functions and have no idea how to test them. A test should be simple and not longer or even more complex than the function it's supposed to test. In that case, the best way forward is to simplify the tested function. Maybe split up some code and so on.

As a result of running through this process over and over again, I learned to write better and more focused code. that actually aims for being simple to test. The last point is working in a team. Eventually, a lot of code written gets seen by other people.

If you're coding on your next big startup with your friends, you don't want to break code by accident. You do not want your users to experience an app in a broken state, and you don't want colleagues to break your code either. Writing tests when working in a team is the most important tool you have to succeed and progress your application. by avoiding to fix broken things over and over again.

Think of any large open source project that you might be using. I guarantee you that every successful project is backed by quality tests written to ensure the stability of the software.