Friday, April 13, 2007

Writing Unit Tests For TDD Backwards

Today, co-worker asked me how to write a unit test.

I basically explained to him that we write them backwards:


1. Write the test’s Description using “Proves correctly …”
2. Write your Assert(s) – Each needs to describe its own “Proves…” and that “Proves..” must support the overarching “Proves…”
3. Write your Exectution – The SINGLE statement that invokes the target of the test
4. Write your Setup

When you do the above steps, everything becomes very focused and clear.

No comments: