Now that you have an idea about what testing is and why we need it, let's introduce the developer's best friend: the unit test.
Before we proceed with the examples, allow me to share some words of caution: I'll try to give you the fundamentals about unit testing, but I don't follow any particular school of thought or methodology to the letter. Over the years, I have tried many different testing approaches, eventually coming up with my own way of doing things, which is constantly evolving. To put it as Bruce Lee would have:
"Absorb what is useful, discard what is useless and add what is specifically your own."