Using UML for Automatic Test Generation Alessandra Cavarra Jim Davies Oxford University Computing Laboratory ale@comlab.ox.ac.uk, jdavies@comlab.ox.ac.uk Thierry Jeron Laurent Mounier IRISA / INRIA Rennes/ VERIMAG–Centre Equation thierry.jeron@irisa.fr, laurent.mounier@imag.fr Alan Hartman Sergey Olvovsky IBM Haifa Research Laboratory hartman@il.ibm.com, olvovsky@il.ibm.com ABSTRACT This paper presents an architecture for model-based testing using a profile of the Unified Modeling Language (UML). Class, object, and state diagrams are used to define essential models: descriptions that characterise the entire range of possible behaviours, in terms of the actions and events of the model. Object and state diagrams are used to introduce test directives. Models written in this profile may be compiled into a tool language: the Intermediate Format (IF). Descriptions writ- ten in IF can be animated, verified, and used to generate tests. As well as illustrating the testing tool adopted, the paper defines the profile for UML, explains testing direc- tives, the basis of the compilation into IF and of the test generation process, and reports upon the problems encoun- tered. 1. INTRODUCTION Software systems are extremely complex; the amount of information contained in a system implementation is hard to comprehend in its entirety. As we cannot test without first understanding what the implementation is supposed to do, we need a way to manage this complexity. A well-known technique to do this is the creation of a suitable model of the system. The suitability of a model depends upon the intended ap- plication. Clearly, we must include every piece of informa- tion that is relevant to our purpose, but we must also try to exclude any piece of information that is not. A model with too much information may be difficult to comprehend, and too complex for automated software engineering. A model that is entirely suitable for one purpose may be less suitable for another: some vital piece of information may be miss- ing. If we have several purposes in mind, then we may need several different models of the same system. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. ISSTA 2002 Rome, Italy Copyright 2001 ACM X-XXXXX-XX-X/XX/XX ...$5.00. In this paper, we describe a modelling architecture for the purposes of model-based verification and testing. We ex- plain how the resulting models can be translated—automati- cally—into a language of state machines, animated, verified, and used as a basis for automatic test generation. Models and test directives are described using the Unified Model- ing Language (UML) [12], although the architecture could be applied to any modeling language with a suitable, state- machine semantics. This work is being carried out as part of the EU-funded AGEDIS project [20]; the acronym is formed from the phrase Automated Generation and Execution of test suites for DIs- tributed component-based Software. The project involves seven industrial and academic research centres. The work is coordinated by IBM Research, Haifa; the academic contrib- utors are the University of Oxford, IRISA, and the Univer- sit´ e Joseph Fourier, Grenoble. The industrial partners are France Telecom, IBM Hursley (UK); Intrasoft International (Luxembourg); and imbus AG (Germany). The aim of the project is to develop methods and tools for the automation of software testing, with particular empha- sis on the testing of distributed, component-based systems; the project started in November 2000, and is expected to run until October 2003. The academic contribution is to define the modelling language, describe a suitable seman- tics, address the problems of complexity, and to design and implement the new test generation tool from the existing ones. We begin with a description of the architecture itself. In Section 3, we define a UML profile for test models. In Sec- tion 4, we introduce test directives and describe the language for test directives. In Section 5, we explain how models are compiled into the Intermediate Format (IF). In Section 6 we explain the principles behind the use of these models for the generation of test suites. We end with a discussion of related and future work. Finally, an example is presented in Appendix A. 2. ARCHITECTURE The first component of the architecture is the system model, written in UML; this is a collection of class, state, and object diagrams: the class diagram identifies the entities in the system; the state diagrams—one for each class—explain how these entities may evolve; the object diagram specifies an initial configuration.