A colleague of mine was once at a seminar about agile development, where he heard it is possible to use unit tests as technical documentation. Something like using unit tests as an example of 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 technical documentation, are there some guidelines on how to implement such unit tests?