Unit Testing Guidelines

Keep it simple.

Test are meant to verify that some piece of code performs some specific operation. If you are having trouble identifying how to create the test, you probably need to rethink what you are coding.

Code wants to be simple - don’t stand in the way of that dream.

Defects/Bugs

Before fixing a defect, write a test that exposes the defect. This unit test provides three benefits:

  1. This test will be very useful later to catch the defect if you do not fix it properly.
  2. Your test suite is now more comprehensive.
  3. You will most probably be too busy to write the test after you have already fixed the defect.