Does it really pay off to do Unit Testing? According to a study conducted at Microsoft it does. The study quotes an increase in development time of about 30% in order to get decent code coverage. The benefits are a reduction of bugs found in verification of 20% and a total decrease in defects/LOC of 60-90%.
This also leads to qualitative benefits such as “help me produce higher quality code” and “write solid code from the start” as well as having fewer bugs in areas of the code covered by unit tests.
So, how does this improve the overall productivity of the developer? Assume that a developer spends D % of his or her time on development, including writing unit tests, C % on bug corrections and O % on other tasks. Assume for the sake of simplicity that the developer time is equally distributed between the three types of activities.
Increasing the time spent on development by 30% leads to perhaps 75% less time spent on corrections. Thus the new mix is D’=D*1,3 = 43%, C’=C*0,25=8% and O’=O. The sum is D’+C’+O’=84%. Consequently, 16% is freed up.
What’s your mix between Developement, Corrections and Other? What will your benefits from implementing unit testing be?