Unit testing is commonly automated, but may still be performed manually. The
IEEE does not favor one over the other. A manual approach to unit testing may
employ a step-by-step instructional document. Nevertheless, the objective in
unit testing is to isolate a unit and validate its correctness. Automation is
efficient for achieving this, and enables the many benefits listed in this
article. Conversely, if not planned carefully, a careless manual unit test case
may execute as an integration test case that involves many software components,
and thus preclude the achievement of most if not all of the goals established
for unit testing.
Under the automated approach, to fully realize the effect of isolation, the
unit or code body subjected to the unit test is executed within a framework
outside of its natural environment, that is, outside of the product or calling
context for which it was originally created. Testing in an isolated manner has
the benefit of revealing unnecessary dependencies between the code being tested
and other units or data spaces in the product. These dependencies can then be
eliminated.
Using an automation framework, the developer codes criteria into the test to
verify the correctness of the unit. During execution of the test cases, the
framework logs those that fail any criterion. Many frameworks will also
automatically flag and report in a summary these failed test cases. Depending
upon the severity of a failure, the framework may halt subsequent testing.
As a consequence, unit testing is traditionally a motivator for programmers
to create decoupled and cohesive code bodies. This practice promotes healthy
habits in software development. Design patterns, unit testing, and refactoring
often work together so that the most ideal solution may emerge.