As much as some people may not like to admit it, we are all human and therefore all susceptible to human error (except for you robots out there, I see you). How many times in life do you wish a big warning sign could have flashed above your head and let you know that you're making a mistake long before it could negatively impact your life? Personally, I can think of several times where this would have been very helpful!
While this isn’t possible in the real world, it is possible in the coding world.
When developers are working it is easy to make a little mistake. You might even have made a mental note to go back and fix it later when you’ve reached the end of the creative flow, only to have then forgotten about it. Later, you get it ready to deploy or to demo to a client and you receive a big juicy error message! Of course, there is no harm in making a mistake but we would like to avoid it if possible, especially if it is relatively easy to fix.
Here is where code testing comes in; do you make sure to write code tests? If you test your code as you go then you are covering your bases for any potential mistakes!
There are two key types of tests, Manual Testing and Automated Testing, the names are fairly self-explanatory but we will discuss them nevertheless.
With Manual Testing, you manually go through the code and ensure each element does what it is intended to do. While this is a thorough way of testing, it is unmanageable to maintain as the code-base grows. It is not possible to look through months of code to try and find 1 tiny potential error.
This is where Automated Testing comes into play. After you finish writing a new component, you spend a short amount of time writing some code specifically designed to test the production code you’ve completed. It runs and verifies that your code does what you want it to do on every level, be it small level, unit tests, larger tests, end-to-end tests, integration tests - the overall application. It might seem like a hassle in the moment, especially if there is a time crunch to get out the code you’ve written, but your future self will thank you!
As more code is written and integrated, these tests will run and immediately notify you if there is an issue and precisely where the issue is - it couldn’t be easier. If the test is passing, then the code passes. No more realising there is an issue only after it has been pushed to release.
It could be compared to spending a short amount of time each day dusting the surfaces so that months down the road you don’t have mountains of dust to clear!
As Automated Testing is a relatively new practice in the grand-scheme of things, a lot of people still don’t implement it in their workflows. Learning new ways of working can be intimidating or seem unnecessary, you may be saying “The way I have done things has been fine for years, why should I change now?”, but this way of thinking is the antithesis of progression, a.k.a. the foundation of development.
At the end of the day, sometimes you need to make a special effort to integrate a new step into your workflow and it will soon become as habitual as having your morning coffee.
I hope this has highlighted the immense value that testing has in the development process and encourages you to include it in your process if you don’t already.