Unit/Module Testing
Larry J. Morell, John Marciniak · Encyclopedia of Software Engineering · 2002
Abstract A software unit is a low level component of a software system with its own specification. A unit may be as small as a commercial block of code or as large as a set of coupled routines. In some cases a unit is referred to as amodule. A module is sometimes used to describe a small subsystem composed of several “units.” For the purposes of this article, the termsunitandmodulewill be used interchangeably, referring to the types of testing employed at the lowest level of system decomposition. The techniques described, however, have greater applicability to testing outside of the unit or module. Testing directed to a single module or unit is calledmoduleorunit testing. It consists of test planning, test data development, test monitoring and execution, and evaluation of results. Test planning involves specifying the adequacy criterion by which to judge the test, assessing the project constraints and resources available, selecting the testing techniques that will achieve the adequacy criteria within the given constraints, and scheduling the testing process. Developing test data includes specifying test data characteristics as well as selecting test data with those characteristics. To execute the module with the selected test data requires adriverfor supplying the test data, monitoring the execution, and capturing the results.Stubsare sometimes needed to simulate the behavior of unimplemented routines that are called within the module. The module may need to beinstrumentedwith additional code to display internal behavior. Evaluating the results determines the success of the executions as well as the degree to which the adequacy criterion was satisfied. After finishing the test of a given module, a decision must be made as to whether or not the module has sufficient quality to be included in the system. The goal of module testing is therefore to enable a more informed decision. Relevant information includes both the results of the test execution and the testcoverage. Coverage may be specified in terms of the specification, the implementation, or a set of potential errors. Adequacy criteria are typically specified in terms of one or more of these three coverages. Each coverage gives rise to a class of testing techniques. Different testing techniques catch different types of faults; a comprehensive testing program will incorporate techniques from each of the classes as mentioned.