Published in IET Software Received on 31st October 2006 Revised on 11th October 2007 doi: 10.1049/iet-sen:20060061 ISSN 1751-8806 Automatic test case generation using unified modeling language (UML) state diagrams P. Samuel R. Mall A.K. Bothra Department of Computer Science and Engineering, Indian Institute of Technology, Kharagpur 721302, West Bengal, India E-mail: philips@cusat.ac.in Abstract: UML is widely accepted and used by industry for modelling and design of software systems. A novel method to automatically generate test cases based on UML state models is presented. In the present approach, the control and data flow logic available in the UML state diagram to generate test data are exploited.The state machine graph is traversed and the conditional predicates on every transition are selected. Then these conditional predicates are transformed and function minimisation technique is applied to generate test cases. The present test data generation scheme is fully automatic and the generated test cases satisfy transition path coverage criteria. The generated test cases can be used to test class as well as cluster-level state-dependent behaviours. 1 Introduction UML has become the de facto standard for object- oriented modelling and design. It is widely accepted and used by industry. The popularity of UML has lead to program development environments getting integrated with modelling tools based on UML. Although UML is intended to produce rigorous models, often incomplete, inconsistent and ambiguous models result in practice. This occurs because of the semi-formal nature of UML and the vast flexibilities provided by it. Still UML models are an important source of information for test case design. UML-based automatic test case generation has therefore turned out to be a practically important and theoretically challenging topic. No wonder then, that it is receiving increasing attention from researchers. Effective testing of software is necessary to produce reliable systems. This is true in practice since static verification techniques have their own limitations [1]. Effective testing, however, is one of the most demanding tasks in software development. In a typical software development project, more than 50% of development effort is typically spent on testing [2, 3]. Both test case design and test case executions are time consuming and labor intensive. Hence, automation of test case generation is an important issue. Often, test cases are generated based on program source code. Generating test models like control flow graph from source code is cumbersome. This is especially true of large programs. In reverse engineering of source code into models, programmers tend to take the easy path and base their abstractions too closely upon the attributes of the implementation. In most cases, the resulting abstractions are quite uninformative. For example, state diagrams tend to have a single state, with transitions labelled with large amounts of translated code [4]. Further, test case generation based on program source code proves to be inadequate in case of component-based software development, where even the source code may not be available to the developers. Hence, test case generation based on design specifications is important. With this, reverse engineering of source code to a test model is avoided. Instead, the same model built for design is used for test generation. Further, test case generation from design specifications has the added advantage of allowing test cases to be available early in the software development cycle, thereby making test planning more effective. It is therefore advantageous to generate test cases from the software design or analysis documents, rather than the code. An automated model-driven test generation framework, & The Institution of Engineering and Technology 2008 IET Softw., 2008, Vol. 2, No. 2, pp. 79–93 / doi: 10.1049/iet-sen:20060061 79 www.ietdl.org