Interclass Testing of Object Oriented Software Vincenzo Martena Politecnico di Milano Dip. di Elettronica e Informazione martena@elet.polimi.it Alessandro Orso Georgia Inst. of Technology College of Computing orso@cc.gatech.edu Mauro Pezz` e Universit` a degli Studi di Milano Bicocca - DISCo pezze@disco.unimib.it Abstract The characteristics of object-oriented software affect type and relevance of faults. In particular, the state of the objects may cause faults that cannot be easily revealed with traditional testing techniques. This paper proposes a new technique for interclass testing, that is, the problem of de- riving test cases for suitably exercising interactions among clusters of classes. The proposed technique uses data-flow analysis for deriving a suitable set of test case specifica- tions for interclass testing. The paper then shows how to automatically generate feasible test cases that satisfy the derived specifications using symbolic execution and auto- mated deduction. Finally, the paper demonstrates the effec- tiveness of the proposed technique by deriving test cases for a microscope controller developed for the European Space Laboratory of the Columbus Orbital Facility. 1. Introduction The object-oriented paradigm is successfully applied in many software projects, and the use of object-oriented lan- guages is increasingly widespread. Object-oriented tech- nologies can reduce or eliminate some problems typical of procedural software, but may introduce new problems that can result in classes of faults hardly addressable with traditional testing techniques [2, 30]. In particular, state- dependent faults tend to occur more frequently in object- oriented software than in procedural software; almost all objects have an associated state, and the behavior of meth- ods invoked on an object depends in general on the object’s state. Such faults can be very difficult to reveal because they cause failures only when the objects are exercised in particular states. In this paper, we extend our previous results in the auto- matic generation of test cases for single classes [3] to ad- dress the problem of interclass testing, i.e., test of interac- tions among classes. We present a technique that automati- cally produces test case specifications from object oriented code, and automatically generates feasible test cases for a subset of object oriented programs that include most safety critical applications. The technique incrementally generates test cases starting from simple classes (i.e., classes with scalar instance variables only) and then moving to more complex classes (i.e., classes whose instance variables are objects or references to objects). In the paper, we also present an empirical validation of the technique. We describe our prototype tool that imple- ments the technique and illustrate how we used the tool to generate test cases for a microscope controller developed for the European Space Laboratory of the Columbus Orbital Facility. 2. Background In previous work, we presented a technique for intra- class testing 1 that allows for generating test cases for sin- gle classes [3]. In this section, we present the essential in- formation required to understand the technique proposed in this paper for interclass testing. The technique is based on the idea that the execution of a method is affected by the in- stance variables used by the method, and thus by the meth- ods that determine the values of such variables. Therefore, we identify pairs of methods that define and use the same instance variable and then try to select a feasible sequence of method invocations that contains the identified definition and use in the correct order. The identified sequences rep- resent the test cases for the target class. The technique consists of three main steps: Data flow analysis. This phase computes def-use asso- ciation, that is, ordered pairs of statements in which the first statement defines and the second statement uses the same instance variable. The def-use association are iden- tified with data-flow analysis of the whole class, focusing on instance variables only. Symbolic execution. This phase computes conditions re- lated to path executions and variable definitions. For every path within each method, we identify the conditions asso- ciated with the execution of that path, the relationship be- tween input and output values of the method with respect 1 Intraclass testing tests the interactions of the methods of a class when they are called in various sequences.