I obviously recommend that everyone use a testing framework.
There are plenty of them out there, and they supply a great deal of the tools
you’ll need for testing. They come in all languages, flavors, and colors. You
might look into these NUnit, MSTest, JUnit, CppUnit. What is important is that
you make sure you know how your tools work so you can test best with them.
I will elaborate on a couple of examples and perhaps down
the road I’ll give some more specific examples.
Some tools show you a list of test names, and only minor
details about why the test failed. For this you usually need to go the
description view or something similar. In these cases it is important to name
your tests effectively.
As an example if I have a method called Add and it takes two
parameters a and b. I might write a test for that method. If I name my test
TestAdd, and that test fails you know something is wrong in that method, but
you do not know what failed. If I had instead made a few more specific methods
you could glean more information from the test having failed. Some examples of
tests I might create are AddTwoZerosShouldBeZero,
AddNumberToZeroShouldBeTheNumber, AddPositiveNumbersTest,
AddNegativeNumbersTest, etc.
Some parts I would lump together like positive numbers and
negative numbers. It is important to handle a couple of different scenarios as
well as the edge cases. I could have done negative and natural numbers and that
would cover all numbers, but I wanted to make sure the edge case, zero, was
handled correctly, so I test it separately.
People can argue back and forth all day long about whether
you should have a lot of small tests or group them together, but this is what
has worked well for me in the past and I hope it works well for you also.