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:
- This test will be very useful later to catch the defect if you do not fix it properly.
- Your test suite is now more comprehensive.
- You will most probably be too busy to write the test after you have already fixed the defect.