Why Unit Testing is Developer's Best Friend
We all know about never stopping fight between the developers and testers in the Software Development and how both of them put their best foot forward to state that they are correct. Being in the industry for quite some time I can say that none of those two are always correct and none of those are always false.
PC: Pinterest.io
Now in some organisation as a developer your incentive or your yearly reivew directly proportional on how many bugs has been encountered on your feature. Thus we developers always wants to give as buggy feature as much as possible. But being a developer we always miss some edgy case.
Now this is where the unit test can come into picture. Let's take an example of a React app where almost everything is been written as a component. Inside a component we have a lot of components life cycle as well as some functions. Now whenever I write a function I make sure that function should have been pass through unit tests with multiple inputs. If it passes I can continue writing more functions.
In that way you are not only following the test driven development but also you know all the possible values your function can get and how to not miss those edgy case. One more thing I tend to follow is that more than 90% of the lines of code which I write should have an equivalent test case written which means that my code coverage should always show percentage more than 90.
Though it's easy to say than done because of the tight deadline or any thing which developer has to consider. But when you follow agile first thing to do it to allocate some time for unit test too along with writing case in that way everyone will know that if you want less buggy software you need to give time to the developer for testing his own feature.