Article: The key aspect of a good unit test is that it checks just one portion of a program. Whether you are looking to test an existing program, or planning tests for a program that isn't written yet, you'll need to break it down into discrete parts ("units"). You'll then write a unit test for each one. The definition of a "unit" varies widely depending on the type of program you are developing. A unit could be a class, but also a single function or procedure. A unit test can be used to check two kinds of scenarios. State-based testing is used to see if a program unit produces proper or expected results. Interaction-based testing, on the other hand, is used to see if a unit sets anticipated methods into action. To write a good test, you'll need to identify what you are trying to test for, so keep one of these approaches in mind as a model. Keep in mind that you'll need to write lots and lots of unit tests. You'll want to run a unit test for every portion of your program. Keeping your tests simple will have several benefits: Simple tests will help ensure that you really are testing only one unit at a time. The tests' code will be reliable. If you have complex test code, it will be more prone to problems, making it just that harder to see bugs in the code of the program you are testing. The tests will be faster, decreasing the overall amount of time it takes to do the testing. A simple test will be readable, meaning you may see some potential problems just by looking at the code itself. Seasoned developers know that there are different ways to test a program. Unit tests are narrow, specific, and look at only one portion of a program. Integration tests, on the other hand, look at the whole program in a real environment. In other words, unit testing ensures that the individual parts of a program work, while integration testing verifies that the parts work together. Integration tests also usually require external elements, such as web servers or a database. To keep unit tests controlled, write them so that they don't require external elements.

What is a summary?
Map your program into units. Determine if you need state-based or interaction-based testing. Plan simple and readable tests. Differentiate unit tests from integration tests.