Universal Environments: Unit testing involves the definition of drivers and stubs. Drivers are program components that invoke operations on the unit under test. Stubs are program components that implement operations invoked by the unit. Stubs and drivers can be defined to also represent parallel contexts representing those portions of an application that execute in parallel with and engage in inter-thread communication with the procedures and threads of the software unit under test. In a similar way, environment models consist of a collection of drivers and stubs that together with the analyzed unit form a closed system that is amenable to model checking. The universal environment is capable of invoking (or refusing) any operation to or from the unit, in any order.
To construct such environments, you need a description of the classes, interfaces, and packages that make up the unit, and the unit operations that are possible. These comprise the method (procedure) invocations in the unit’s interface, methods invoked by the unit, global variables changing their values, etc. For simplicity, in this chapter we phrase our discussion and examples in terms of the Java language. In this case, a software component can be a Java class and the operations are its public methods and the methods invoked by the class, together with the global variables such as public fields that change their value.