Title: RE: [OT] Cost / benefit unit test questionnaire

Hi Heikki!

> -----Mensaje original-----
> De: Heikki Doeleman [mailto:[EMAIL PROTECTED]]
> Enviado el: lunes 24 de septiembre de 2001 11:21
> Para: '[EMAIL PROTECTED]'
> Asunto: Cost / benefit unit test questionnaire
>
>
> Hi
>
> please allow me these slightly off-topic questions :
>
> in order to convince management at my company that writing
> automatic unit
> tests is not only cheaper for code maintenance but speeds up
> the development
> effort at -all- project phases, I would appreciate your
> feedback on the
> following questions:

If you are adding unit tests to existing code, then consider doing it in small steps -- adding tests just for code that is being modified. Anyway, the info you request can be found on any of a number of XP books. I give you our particulars below.

> - what percentage of time do you spend writing application
> code, and writing
> unit tests?

The percentage of unit test code is about 25%. This suggests that it takes 1/4 of the time, but in fact it's not that much: unit tests do not need to be refactored at all.

> - what percentage of time do you spend bug fixing and debugging?

Not as much as coding. Cannot tell you anything more specific.

> - if unit testing was introduced in your company while you were there,
> please tell me something about the effects on delivery time?

I can tell you that error rates on delivery have dramatically gone down, which has a huge impact on product quality and testing costs.

Also, productivity has gone up a lot. Since I don't have figures before unit tests, all I can tell is that now we do about 100 debugged lines of code a day (two developers).

Acceptance tests used to have about 10 errors per 1000 lines of code (10 / 1KLOC). Now it's less than 1 / 1KLOC. Since bug-removal costs can be as much as 50 times higher in this later phase, you can tell the cost-benefit relationship of writing unit tests.

OK, I'll do the math, supposing productivity is about the same in both scenarios. Let's suppose a system with size 1 KLOC. It has 10 errors, and it will take about a day to fix each one (including detection and reporting times). Productivity of 100 LOC/day suggests that the system will take about 10 days to code, and then ten errors will cost some 10 days more. Total time: 20 days.

With unit tests, system size increases about 25%, so it would take 12.5 days to code and unit-test. From the 10 errors yielded before, ten will be caught in unit tests, and they will probably take a day to solve. The remaining bug will take another day. So total coding + testing times will be about 12.5 + 1 + 1 = 14.5 days.

It's worth it, and it's much more fun this way: no more endless days solving unending bugs :)

Un saludo,

Alex.

Reply via email to