5 Reasons Testing Code Is Great

Developers are an odd bunch. We agree that best practices should be followed at all times. Right? Then we get to testing. Some developers love writing tests and some go out of their way to avoid it. I just wanted to list a few reasons why you most definitely should write tests.

They save you hours of debugging.

You’ll catch all of those little things, like syntax errors or the wrong values getting passed, that sometimes make it to the next phase in your pipeline. After you’ve written a bunch of code for the application, it will take you longer to find those small things compared to finding them immediately with your unit tests.

They make you think about your code before/as you write it.

What parameters should you expect? Why are you writing the code a specific way? How do you think the user could break the code? All of these questions come up when you are writing unit tests and you have to have an answer. By the time you finish a certain task, you’ll know everything about the nuts and bolts behind it.

They make you write efficient code the first time.

Writing unit tests helps you keep your code simple because you write just enough code to pass the test. Having simple, easy to read, bug-resistant code in your first round of programming makes you more confident as a developer and it makes your employers have more confidence in you too.

They give you documentation for the application.

This can be the best source of documentation you could ever wish for. When new bugs crawl out or you need to add new features, you’ll have a way to make sure none of your changes are breaking any current functionality. You’ll also have a way to find out where you should start debugging or building new functionality.

They help keep deploys smooth.

It’s a completely different story when you have testing in place. If there is a something broken in the code after a merge, the tests will most likely find it and tell you what’s wrong. Then your panic time might be a few minutes instead of hours. This last minute check can save you a lot of problems with clients and managers. It’s better to be able to tell them that you know what the problem is versus not knowing anything and saying it worked on your machine.

Those are a few reasons I write as many tests as I can. Sure it takes more time in the beginning, but it makes a Friday night deploy a whole lot better. What are your thoughts on writing unit tests?

Hey! You should follow me on Twitter because reasons: https://twitter.com/FlippedCoding

Starting classes soon! | Software/Hardware Engineer | International tech speaker | Random inventor and slightly mad scientist with extra sauce