|
Definition: By knowing the inner logic the program the
test what you conduct is Unit Testing. or Testing the piece/unit of a program
Unit testing
is a procedure used to validate that a particular
module of
source code is
working properly. The procedure is to write test cases for all
functions and
methods so
that whenever a change causes a
regression, it
can be quickly identified and fixed.

Benefits:
The goal of unit testing
is to isolate each part of the program and show that the individual parts are
correct. Unit testing provides a strict, written contract that the piece of code
must satisfy. As a result, it affords several benefits.
1) Facilitates Change
2) Simplifies Integration
3) Documentation
4) Separation of Interface from Implementation
Limitations of Unit Testing:
Unit-testing
will not catch every error in the program. By definition, it only tests the
functionality of the units themselves. Therefore, it will not catch integration
errors,
performance
problems or any other system-wide issues. In addition, it may not be easy to
anticipate all special cases of input the program unit under study may receive
in reality. Unit testing is only effective if it is used in conjunction with
other
software testing
activities.
It is unrealistic to test all possible input combinations for any non-trivial
piece of software. A unit test can only show the presence of errors; it cannot
show the absence of errors. Though these two limitations apply to any form of
software test.
Charles'
Six Rules of Unit Testing
1.
Write the
test first
2.
Never write a
test that succeeds the first time
3.
Start with the
null case, or something that doesn't work
4.
Don't be afraid
of doing something trivial to make the test work
5.
Loose coupling
and testability go hand in hand
6.
Use mock objects
|