Mutation Testing Based on OCL Specifications and Aspect Oriented Programming Luciano C. Ascari, Silvia R. Vergilio Computer Science Department, Federal University of Paran´ a - UFPR CP: 19081, CEP: 81531-970 Curitiba, Brazil Email: luascari@gmail.com, silvia@inf.ufpr.br Abstract—Mutation based testing has been considered in many experiments as the most efficacious in terms of revealed faults, but also the most expensive, considering the number of executions. Other problem is that the test data are generally derived from the programs and do not ensure the discovering of faults usually reveald with test data generated from the specification, such as missing paths, which are no-implemented functionalities. Nowadays the use of OCL specifications to generate test data and overcome this limitation has gained importance. Some works propose to enforce OCL constraints by using Aspect Oriented Programming (AOP). However, OCL specifications can be incorrect too. Because of this, in this paper, we propose a testing approach for class testing, which is based on mutation of OCL specifications and AOP. It allows the validation of the implemented code according to the specification and by considering specification faults. The main uses of the approach are illustrated through a case study. Experimental results show its applicability. Keywords-mutation test; aspect oriented programming; test criteria and tools; I. I NTRODUCTION Software testing is a fundamental activity for ensuring soft- ware quality. In general, three techniques can be used in this activity: structural, functional and fault-based. Each technique is associated to different test criteria, which guide the selection of test data, and offer coverage measures to evaluate a test set and to consider the program enough tested [1]. In experiments reported in the literature, the fault based criteria have been considered the most efficacious, in terms of revealed faults, but the most expensive considering the number of test data and executions of the program [2]. The most known and used fault-based criterion is mutation analysis [3], [4]. The goal is to change the program P under test by using some mutation operators. Each modified program is named mutant and describes a common fault that can be present in P. Test data are required to kill each generated mutant, that is, to produce outputs that are different from outputs of P. The difference can show a fault in P, if the mutant output is the expected one. The mutation test and other criteria have been applied in the context of object oriented programs. The criteria derive the test requirements based on either specification or programs. Works that are based on the specification testing include the test of different models, such as: use case diagrams [5], [6], state models [7], collaboration and class diagrams [7], [8], contract based testing [9], etc. In this context, the use of OCL (Object Constraint Language Specification) [10] has gained importance to specify the well-formedness rules of the UML metamodels. It is used to write contracts, to specify invariants, pre and post conditions, and so on. In the the context of test based on programs we can mention the application of structural [11], [12] and fault-based criteria [13]. In this context some disadvantages and limita- tions are found, such as missing paths. This happens when a functionality that is correctly described in the specification is not implemented (is absent) in the code. Even the coverage of all-paths in the program does not guarantee that this kind of fault is discovered by the test sets. This happens because the generation of test data is only based on the implementation. Because of this, the selection of test data from the specification (functional test) is fundamental. To overcome this limitation some authors have used the OCL specification for test data generation either to validate the specification models or to validate the implementation [7], [9], [14], [15], [16], [17]. The goal of many works is to verify inconsistencies in the implementation, by checking the specified constraints. With this goal, the use of Aspect Oriented Programming (AOP) presents many advantages, such as: to allow the code instrumentation without changing the source code trough the use of aspects and transversal con- cerns. These works instrument the code with aspects to check OCL constraints during the execution (or generation) of the code [17], [18]. Some authors consider functional test criteria, such as Par- tition Analysis [16] and mutation testing [14], to validate the implementation. Their advantage is the use of a test criterion to guide the test data generation and to provide evaluation coverage measures. However, these works do not make use of assertions and AOP. Considering this advantage, the benefits of AOP and the program based test, this work introduces a test approach that uses the mutation test to guide the generation of test data from OCL specifications. The approach has as fundamental common faults that can be present in the specification, and consider that these faults can be reflected in the code being tested. Beside of this, AOP concepts are used to check if the test data describe these faults, that is, whether they satisfy the XXIX International Conference of the Chilean Computer Science Society 1522-4902/10 $26.00 © 2010 IEEE DOI 10.1109/SCCC.2010.37 43