Wednesday, December 26, 2007

Developers and unit testing

Do developers hate testing ? Strange!
How do developers say the code works and how do they explain about the components they developed ?
To me 'Unit testing' is the only way. Documentation works, but is not enough.

How do you measure your unit tests ?

I write my unit tests for 2 reasons:
1. Unit testing the individual components to assess the working code.
2. As a documentation to other developers who would need to integrate other components with my developed components.
Does it mean the unit tests follow certain order and are coded properly with proper test data. A big YES.

This is 'team work'. No unit tests or poorly coded unit tests mean 'team without work'. Chaos.

One of the Projects I was working on required a lot of integration with other developers' developed components and hence required understanding of those components. How ? Well, an easy answer , bug my co-developers 10 times a day.

The other answer is follow the 'unit tests for this component'. Simple.
The unit test must be able to provide 90% of what the component is all about. It can answer - what, why, when and how. Run the unit tests for yourself and see what it does. This is what a lot of Developers miss about unit tests and unit testing.

This provides a lot of information regarding the other components. The interface to such components, design issues, design patterns and the basic object oriented nature of such compoemnts.