Instruments for Unit Testing
Unit testing tools which to a considerable degree possess unit properties are considered an important class of testing tools. JUnit written in Java is the most well known of these tools. It is aimed for code testing in this language. Historically, however, the first tool was SUnit for Smalltalk programs.
These tools are characterized by high flexibility, the possibility of utilizing completely independent modules for the realization of additional functions and the possibility of use in more complex testing systems. One of the module testing tools with the most diverse functionality is TestNG . Its main characteristics are as follows:
Test Configuration
Basic test elements are test classes and test methods described as Java classes and methods having an @Test annotation.
Test sets are hierarchically structured. They contain separate test suites consisting of tests. Further in this list of characteristics these terms are used in a narrow sense specific for TestNG. Tests and test suites are defined with a test configuration described in a certain XML-format. The test is composed of several classification methods classified according to their names or their belonging to a certain group mentioned in method annotation.
Set-up and tear-down methods are used for the initialization of certain data before tests are completed, and for releasing engaged resources afterwards. These methods may be defined for all hierarchy elements for suites, tests, classes and methods.
It is also possible to define dependencies between test methods and methods and groups which allows for managing the order of their performance and canceling the performance of a test method if one of the testing methods upon which it depends was performed with errors.
Test data and objects
Test methods in TestNG may be parametrizable. The set of parameter points used within the test is marked by means of an additional annotation or in a configuration file and is to be represented either as a specified set of objects or as a sequence of results returned by means of a definite method while the test is on.
Object factories can also be created. They construct various objects of test classes. All the methods included in tests are performed for each such object.
Verification of test results
The chief way of describing checks performed by means of test methods aswith many other instruments of unit testing is the use of an assert? methods library. Each method checks a simple property of its arguments. In the event of an error the method produces a trace message which also appears in form of an argument.
Additionally, TestNG supports pointing out possible exceptions and limitations during while the test method is running in its annotation.
Unit testing tools actively use independently developed units to solve more specific tasks. For example, dbUnit is sued for organizing the work with databases into unit tests and httpUnit is used to process HTTP-requests. For a more instructive record of verifications performed in tests (close to the definition of natural languages) libraries provided by development tools may be applied, based on functionality (behavior driven development), for example, JBehave or NSpecify; Mockito or EasyMock libraries may be used to organize test stubs.


