This site runs best with JavaScript enabled.

Unit testing is more important than you think

Shakil

March 29, 2017


We usually expect the outcome of a function while writing it. However, when your app grows in complexity, it's not possible to keep track of all the functions in your software just in your head. It's unnecessary as well. As engineers, all we do is making things that reduce human effort. So why hurt your brain thinking about whether your current changes will break another feature? leave it to the software to test. Unit testing is testing your function as a small unit of your entire app. Besides making sure your function is working properly, this practice has some beneficial side effects as well.

Keeping the memory burden away
By memory, I mean the short-term memory of our brain that holds temporary data while analyzing things. You can think of so many things at a time. If you are working on a large project, it's just overwhelming to think even about one feature. Unit testing helps you think about one small problem at a time and get that right. And then we add one step on top of that and so on.

Superior error handling
The difference between a good and bad software is that the former handles errors better. Check any repository, you will see that every input is checked against multiple possible cases and perform actions or throw warnings and errors according to that. Unit testing kind of forces you to implement that in the process.

A strategy of software building
It may seem counter-intuitive at first, a large number of developers write the tests first and then code the functions. You write the input scenarios first and then write your code to manipulate that input correctly. The strategy is called Test Driven Development or TDD in short.

Share article