Test Driven Documentation

April 14, 2010 · 0 comments

Part of allowing change to happen during development is by building software with engineering practices that support change. The most important of these practices is correctly using unit tests. Tests represent a way to both embody understanding of the system and prove that the system works.

Unit tests are really a form of specifications because by running them and seeing them succeed we know they are up to date. So we really want to use test as a form of documentation that specifies the behavior of a system.

This implies using unit tests in a different way than many people think of them but it is perhaps the most powerful way to think of using tests. It also guides us for creating the right number of tests. If we see tests as documenting the system then we are not tempted to write more tests than are needed to specify the behavior of the system.

I notice that I can learn a system much more quickly when there are tests in place. I invariably look at the tests first and that tells me how the system should behave. I then look at the production code to see how the behavior is implemented.

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: