Test Case Generation by EFSM Extracted from UML Sequence Diagrams

Test Case Generation by EFSM Extracted from UML Sequence Diagrams

Test Case Generation by EFSM Extracted from UML Sequence Diagrams Mauricio Rocha1;2, Adenilso Simao˜ 1, Thiago Sousa2, Marcelo Batista2 1Instituto de Cienciasˆ Matematicas´ e de Computac¸ao˜ (ICMC), USP, Sao˜ Carlos, SP, Brazil [email protected], [email protected] 2Centro de Tecnologia e Urbanismo (CTU), UESPI, Teresina, PI, Brazil [email protected], [email protected], [email protected] Abstract—The effectiveness of Model-Based Testing (MBT) thus reducing the cost of development. The central idea of is mainly due to the potential for automation it offers. If the MBT is generating input sequences and their expected outputs model is formal and machine-readable, test cases can be derived from a model or specification. The input sequences are then automatically. The Extended Finite State Machine (EFSM) is a formal modeling technique widely used to represent a system. applied to the System Under Test (SUT) and the software However, EFSM is not a common practice in industry. On the outputs are compared to the outputs of the model. This implies other hand, the Unified Modeling Language (UML) has become that the model must be valid, i.e. faithfully represent the the de-facto standard for modeling software, but due to the requirements. Basically, MBT are used for functional black- lack of formal semantics, its diagrams can have ambiguous box testing, where software functionality is examined without interpretations and are not suitable for testing automation. In this context, we present a systematic procedure for generating tests any knowledge of the software’s internal coding. from a UML model. More specifically, our approach proposes a In MBT, it is recommended to use formal models, since mapping from the UML Sequence Diagram into Extended Finite they can be used as a basis for automating the testing process, State Machine in order to provide a precise semantics to them making it more efficient and effective [4]. There are several and uses the ModelJUnit and JUnit libraries in order to generate formal modeling techniques based on state transition machines test cases automatically. Index Terms—Model-Based Testing, Model-Driven Engineer- that can be used to specify a test model. Extended Finite ing, Sequence Diagram, Extended Finite State Machine, Mod- State Machine (EFSM) has been widely used in the formal elJUnit, JUnit methods community, since they make it possible to represent the flow of control and data of complex systems. Moreover, I. INTRODUCTION EFSM can be implemented as a test model using the the A common practice in most software development processes ModelJUnit [5] library, which was designed as an extension is the use of abstract models to aid in the construction of of JUnit. Therefore, the models are written in Java, a popular products. These models represent the essential parts of a programming language. system and allow software engineers to take a conceptual In this context, we present a systematic procedure for view of several different software perspectives. An option for generation of test cases from a UML model. The idea is to use software modeling is the Unified Modeling Language (UML), concepts of Model-Driven Engineering (MDE) to transform since it is widely used and, due to its expressiveness, it is the UML Sequence Diagrams into EFSM and using the possible to model both static and structural aspects as well ModelJUnit and JUnit libraries in order to generate test cases as dynamic or behavioral [1]. However, due to the lack of automatically. In summary, the main contributions of this paper formal semantics, the use of UML can lead to some issues, include: such as inconsistency, transformation problems and different 1) Definition of transformation rules for mapping the ele- interpretations [2]. ments of the UML Sequence Diagram into the Extended An option to minimize these problems is the use of formal Finite State Machine constructions using Atlas Transfor- models, since they have a precise semantics to accurately mation Language (ATL) [6]. represent system behavior. However, what is observed in 2) Formalization of the UML Sequence Diagram into practice is that formal methods are little used in industry, EFSM which is a semantically accurate model. probably due to the lack of training and familiarity with the 3) Automatic source code generation of ModelJUnit and mathematical notation by the developers. JUnit classes from EFSM using Acceleo [7]. In the context of software testing, modeling can increase 4) Systematic procedure to generate Java tests from UML the productivity of this activity. According to Utting et al. [3], Sequence Diagram automatically. Model-Based Testing (MBT) allows the automatic generation II. BACKGROUND of tests from models and other software artifacts, making it A. Sequence Diagram possible to create tests for the software even before coding, The dynamic behavioral aspect of an object-oriented soft- DOI reference number: 10.18293/SEKE2019-133 ware is defined through the interaction of objects and the exchange of messages among them. The main diagram of An EFSM can be formally represented by a 6-tuple (s0, S, the interaction model is the UML Sequence Diagram, which V , I, O, T ) [10], where: presents the interactions between objects in the temporal order • S is a finite set of states with the initial state s0; in which they occur. • V is a finite set of context variables; Lifelines represent participants of the interaction that com- • I is a set of transitions entries; municate via messages. These messages may correspond to • O is a set of transitions outputs; the operation call, signal sending or a return message. More • T is a finite set of transitions. complex interactions can be created using combined fragment. Each transition tx 2 T can also be represented formally by a A combined fragment is used to define control flow in the tuple tx = (s , s , P , A , i , o ), where s , s and i 2 interaction. It can be composed of one or more operands, zero i j tx tx tx tx i j tx I represents the input parameters of the beginning of the state or more interaction constraints, and an interaction operator. transition tx and o 2 O represents the output parameter at An operand corresponds to a sequence of messages that tx the end of the state transition tx. In addition, P represents are executed only under specific circumstances. Interaction tx the predicate conditions (guards) with their respective context constraints are also known as guard conditions and represent variables and A the operators (actions) with their respective a conditional expression. tx current variables. In this paper, we use three interaction operators that model the main procedural constructs: D. Model-Based Testing • alt: construction of the if-then-else type. Only one The software test aims to perform an implementation of operand will be executed. the system under construction with test data and verify that • opt: construction of the if-then type. It is very similar to its operating behavior conforms to its specification. This the alt operator, with the difference being that only one implementation being tested is named the System Under Test operand is defined, which may or may not be executed. (SUT). • loop: a construct that represents a loop where the single In MBT, the use of models is motivated by the observation operand is executed zero or more times. that, traditionally, the testing process is unstructured, non- Other interaction operators defined by UML 2, that can be reproducible, undocumented and depends on the creativity of found in OMG (Object Management Group) [1], are not in software engineers. The idea is that artifacts used in SUT the scope of this work. coding can help mitigate these problems [3]. B. Model-Driven Transformation In summary, the MBT covers the processes and techniques for automatic derivation of test cases from abstract software Model transformation is a key concept within the scope models. To achieve success in this activity, rigor is necessary of Model-Driven Engineering (MDE). The MDE aims at in this process. supporting the development of complex software that involves different technologies and application domains, focusing on III. OUR APPROACH models and model transformation [8]. Similarly to models, metamodels play a key role on the In this section we present a systematic process for test MDE. A metamodel makes statements about what can be case generation by EFSM extracted from UML Sequence expressed in valid models of a given modeling language. Diagrams. The Figure 1 illustrates our approach, which is Modeling languages need to have formal definitions so that divided into two main steps as detailed below: transformation tools can automatically transform the models Step 1 - Transformation between models. Scenarios are built into those languages. The OMG has created a special written in the form of the UML Sequence Diagram. This language called Meta Object Facility (MOF) [9], which is the UML Sequence Diagram is transformed into an EFSM through default metalanguage for all modeling languages. Thus, each the mapping between their respective metamodels using Atlas language is defined by means of a metamodel using the MOF. Transformation Language (ATL). The result of this step is a Model transformation is the generation of a target model formal software model represented by an EFSM. from a source model. This generation process consists of a Step 2 - Generation of test cases. From a model of the set of transformation rules that describes how the elements software represented by EFSM, the test cases are generated of the source model are mapped into elements of the target using EFSM-based test generation methods from ModelJUnit model. The transformations can be performed in two ways: and JUnit libraries. In this step, a Model-To-Text (M2T) Model-To-Model (M2M) mapping or Model-To-Text (M2T) transformation is performed using Acceleo, resulting in a set mapping.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us