What tests are really for

Buried deep in this Giles Bowkett post is the following gem:

“Tests are absolutely not for checking to see if things went wrong. They are for articulating what code should do, and proving that code does it.”

While it comes in the midst of an anti-debugger post (and an extended explanation of why comments on the post are closed), it is an excellent and concise statement of the purpose of unit tests.  It explains perhaps better than anything else I’ve read the main reason unit tests (or specifications, as the author would call them) should be written before the code.