Unit testing provides a sort of living documentation of the system.
Developers looking to learn what functionality is provided by a unit and how to
use it can look at the unit tests to gain a basic understanding of the unit API.
Unit test cases embody characteristics that are critical to the success of
the unit. These characteristics can indicate appropriate/inappropriate use of a
unit as well as negative behaviors that are to be trapped by the unit. A unit
test case, in and of itself, documents these critical characteristics, although
many software development environments do not rely solely upon code to document
the product in development.
On the other hand, ordinary narrative documentation is more susceptible to
drifting from the implementation of the program and will thus become outdated
(e.g. design changes, feature creep, relaxed practices to keep documents up to
date).