As you may have noticed, there are many things that can go wrong when writing code. Unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In procedural programming, a unit may be an individual function or procedure. In object-oriented programming, a unit is usually an interface or a class. We can separate what needs to be tested for each class into different catagories in order to make testing an easier process.
- Testing to make sure class invariants are maintained
- Testing to ensure that method pre-conditions are upheld
- Testing to ensure that method post-conditions are verified
- Testing for general cases
- Testing for edge cases