The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits.
Unit testing allows the programmer to refactor code at a later date, and make
sure the module still works correctly (i.e. regression testing). The procedure
is to write test cases for all functions and methods so that whenever a change
causes a fault, it can be quickly identified and fixed.
Readily-available unit tests make it easy for the programmer to check whether
a piece of code is still working properly. Good unit test design produces test
cases that cover all paths through the unit with attention paid to loop
In continuous unit testing environments, through the inherent practice of
sustained maintenance, unit tests will continue to accurately reflect the
intended use of the executable and code in the face of any change. Depending
upon established development practices and unit test coverage, up-to-the-second
accuracy can be maintained.