A colleague of mine was one a seminar about agile development, where he heard it is possible to use unit tests as a technical documentation. Something like using unit tests as example how to use the class.
A quick google search provided TDD and Documentation, which proves it should be possible. But looking at our code, I see that we obviously failed to implement unit tests in such a way.
In my opinion unit tests are there to test code as a minimal unit, even with help of mock and fake classes and functions.
So, the questions are :
- isn't it the task of functional tests to show how a class (or set of classes) should be used?
- if it is possible to use unit tests as a technical documentation, are there some guidelines on how to implement such unit tests?