Are unit tests really used as documentation?

Posted by stijn on Programmers See other posts from Programmers or by stijn
Published on 2012-06-28T07:32:23Z Indexed on 2012/06/28 9:22 UTC
Read the original article Hit count: 270

Filed under:
|

I cannot count the number of times I read statements in the vein of 'unit tests are a very important source of documentation of the code under test'. I do not deny they are true.

But personally I haven't found myself using them as documentation, ever. For the typical frameworks I use, the method declarations document their behaviour and that's all I need. And I assume the unit tests backup everything stated in that documentation, plus likely some more internal stuff, so on one side it duplicates the ducumentation while on the other it might add some more that is irrelevant.

So the question is: when are unit tests used as documentation? When the comments do not cover everything? By developpers extending the source? And what do they expose that can be useful and relevant that the documentation itself cannot expose?

© Programmers or respective owner

Related posts about unit-testing

Related posts about documentation