scieee Open visual document viewer

Towards the Automation of Metamorphic Testing in Model Transformations

Troya Castilla, Javier; Segura Rueda, Sergio; Ruiz Cortés, Antonio

Abstract

Model transformations are the cornerstone of Model-Driven Engineering, and provide the essential mechanisms for manipulating and transforming models. Checking whether the output of a model transformation is correct is a manual and error-prone task, this is referred to as the oracle problem in the software testing literature. The correctness of the model transformation program is crucial for the proper generation of its output, so it should be tested. Metamorphic testing is a testing technique to alleviate the oracle problem consisting on exploiting the relations between different inputs and outputs of the program under test, so-called metamorphic relations. In this paper we give an insight into our approach to generically define metamorphic relations for model transformations, which can be automatically instantiated given any specific model transformation.

Full text

281 XXI Jo nadas de Ingenie ía del So wa e y Bases de Da os, pp. 281-284 © Ediciones Uni e sidad de Salamanca Towa ds he Au oma ion o Me amo phic Tes ing in Model T ans o ma ions Ja ie T oya, Se gio Segu a, and An onio Ruiz-Co ´ es Depa men o Compu e Languages and Sys ems Uni e sidad de Se illa, Spain {j oya, se giosegu a, a uiz}@us.es Abs ac . Model ans o ma ions a e he co ne s one o Model-D i en Engi- nee ing, and p o ide he essen ial mechanisms o manipula ing and ans o m- ing models. Checking whe he he ou pu o a model ans o ma ion is co ec is a manual and e o -p one ask, his is e e ed o as he o acle p oblem in he so wa e es ing li e a u e. The co ec ness o he model ans o ma ion p og am is c ucial o he p ope gene a ion o i s ou pu , so i should be es ed. Me amo - phic es ing is a es ing echnique o alle ia e he o acle p oblem consis ing on exploi ing he ela ions be ween di e en inpu s and ou pu s o he p og am un- de es , so-called me amo phic ela ions. In his pape we gi e an insigh in o ou app oach o gene ically de ine me amo phic ela ions o model ans o ma ions, which can be au oma ically ins an ia ed gi en any speci ic model ans o ma ion. Keywo ds: Me amo phic Tes ing, Model T ans o ma ion, Au oma ion, Gene ic 1 In oduc ion Model T ans o ma ions (MTs) a e he co ne s one o Model-D i en Enginee ing (MDE). They p o ide he essen ial mechanisms o manipula ing and ans o ming models. Checking whe he he ou pu o a model ans o ma ion is co ec is a manual and e o -p one ask, his is e e eed o as he o acle p oblem in he so wa e es ing li - e a u e. Indeed, he quali y o he gene a ed so wa e a i ac s is highly a ec ed by he co ec ness o he de eloped model ans o ma ions. Fo his eason, se e al app oaches ha e been p oposed ha e i y he co ec beha io o he ans o ma ions using o mal me hods [6,1] o ce i y hei beha io o a selec ed se o es models mainly o iden i y bugs in a cos -e ec i e way [2,7]. Me amo phic Tes ing (MT’) [5] is a me hodology designed o alle ia e he o a- cle p oblem. Di e en om con en ional es ing s a egies, MT’ consis s on exploi ing he ela ions be ween di e en inpu s and ou pu s o he p og am unde es , so-called Me amo phic Rela ions (MRs). In p ac ice, MRs de ine possible modi ica ions o a es inpu and how hose changes a e p opaga ed o he p og am ou pu . A basic example o MR can be de ined o he p og am ha compu es he sine unc ion. Le us suppose we wan o know he exac alue o sin(5). Is an obse ed ou pu o 0.091 co ec ? A ma hema ical p ope y o he sine unc ion s a es ha sin(x) = sin(π−x), and we can use his o es whe he sin(5) = sin(π−5) wi hou knowing he conc e e alues o ei he sine calcula ion. Cu en ly, he bigges limi a ion o MT’ has o do wi h he 282 © Ediciones Uni e sidad de Salamanca ja ie oya, se gio segu a, an onio uiz-co és owa ds he au oma ion o me amo phic es ing in model ans o ma ions XXI Jo nadas de Ingenie ía del So wa e y Bases de Da os, pp. 281-284 2 Towa ds he Au oma ion o Me amo phic Tes ing in Model T ans o ma ions C1: es model (sou ce model) T1: esul model ( a ge model) MTexecu ion C2: ollow‐up es model ( ollow‐upsou ce model) T2: ollow‐up esul model ( ollow‐up a ge model) con olled modi ica ion MTexecu ion Fig. 1: Me amo phic Tes ing in Model T ans o ma ions. de ini ion o he MRs. In ac , he au oma ic gene a ion o MRs has been acknowledged as one o he big challenges in MT’ [5]. Figu e 1 displays he scena io o MT’ in MTs. We ha e a es model (C1), which is ypically he sou ce model. I we apply he MT, we ob ain he esul model (T1), i.e., he a ge model. By applying a con olled modi ica ion in he es model, we ob ain he ollow-up es model (C2). I we now apply he same MT o C2, we ge he ollow-up esul model (T2). In his con ex , a MR conside s he modi ica ion done in C2 wi h espec o C1, and he consequences ha his has in T2 wi h espec o T1. We show an example in nex sec ion. As a as we a e conce ned, he e is only one app oach ha applies MT’ in MTs [3]. The au ho s demons a e he e ec i eness and easibili y o i s applica ion, al hough hey apply i manually in a speci ic scena io, o which hey de ine he MRs. In ou app oach, we p opose o au oma ically gene a e MRs o any model ans o ma ion, as we explain in he nex sec ion. Then, in Sec ion 3 we desc ibe ou nex s eps. 2 App oach The goal o ou app oach is o au oma e he p ocess o me amo phic es ing (MT’) in model ans o ma ions (MTs). The eby, we p opose he au oma ic gene a ion o me a- mo phic ela ions (MRs) o any model ans o ma ion. We wo k wi h ans o ma ions w i en in he ATL T ans o ma ion Language due o i s impo ance bo h in academia and indus y. In o de o au oma ically ex ac in o ma ion ou o a ans o ma ion, we make use o explici ace models. A ace model can be au oma ically ob ained om a ans o - ma ion execu ion, e.g., by using Jouaul ’s T aceAdde [4], and is composed o a se o aces, one o each ule execu ion. A ace cap u es he name o he applied ule and he elemen s o he sou ce model (sou ceElems ela ionship) ha a e used o c ea e new elemen s in he a ge model ( a ge Elems ela ionship). The e o e, by na iga ing he ace model, we know which a ge elemen (s) ha e been c ea ed om which sou ce el- emen (s) and by which ule. A simple example o a gene ic ace is shown in Figu e 2(a). Please no e ha mo e han one elemen may appea as sou ceElems and a ge Elems. We conside his ace as gene ic because each o he h ee elemen s appea ing in i (Sou ceElemen ,T ace and Ta ge Elemen ) can be ins an ia ed in a pa icula scena io. The idea o ou app oach is o de ine gene ic MRs o gene ic aces. These MRs can hen be ins an ia ed oge he wi h he gene ic aces. Fo ins ance, conside ing he gene ic ace o Figu e 2(a), we know ha i we ha e a es model (C1, Figu e 1) and we add an elemen o ype Sou ceElemen in he ollow-up es model (C2), hen an 283 ja ie oya, se gio segu a, an onio uiz-co és owa ds he au oma ion o me amo phic es ing in model ans o ma ions XXI Jo nadas de Ingenie ía del So wa e y Bases de Da os, pp. 281-284 © Ediciones Uni e sidad de Salamanca Towa ds he Au oma ion o Me amo phic Tes ing in Model T ans o ma ions 3 T ace uleName:Da aType2Type Da aType name:S ing Type name:S ing sou ceElems a ge Elems T ace uleName Sou ceElemen sou ceElems a ge Elems Ta ge Elemen T ace uleName:Class2Table Class name:School Table name:School sou ceElems a ge Elems Column name:objec Id key ype (a) Simple Gene ic T ace. T ace uleName:Da aType2Type Da aType name:S ing Type name:S ing sou ceElems a ge Elems T ace uleName Sou ceElemen sou ceElems a ge Elems Ta ge Elemen T ace uleName:Class2Table Class name:School Table name:School sou ceElems a ge Elems Column name:objec Id key ype (b) T aces o he ans o ma ion exce p o Lis ing 1.2. Fig. 2: Gene ic and ins an ia ed aces elemen o ype Ta ge Elemen is c ea ed o i in he ollow-up esul model (T2). This means ha T2 has one mo e elemen o his ype han T1. Ha ing his in o ma ion in o accoun , we can de ine he i s gene ic MR shown in Lis ing 1.1, w i en in he OCL language. Besides, he numbe o elemen s o any o he ype should emain he same in T1 and T2, so u he MRs can be de ined, such as he second one in he same lis ing. Lis ing 1.1: Gene ic MRs o he addi ion o a Sou ceElemen 1T1_Ta ge Elemen .allIns ances()->size()=T2_Ta ge Elemen .allIns ances()->size()-1 2T1_AnyO he Type.allIns ances()->size()=T2_AnyO he Type.allIns ances()->size() In o de o show an example o ins an ia ion o he gene ic MRs shown be o e, we choose he well-known Class2Rela ional case s udy. We will ocus on he exce p o he ans o ma ion, which has been sligh ly modi ied o simplici y in he explana ion, shown in Lis ing 1.2. I we ha e a sou ce model wi h a Da aType and a Class and we apply he ans o ma ion, he esul ing ace model is depic ed in Figu e 2(b). We can see a ace ha e lec s he c ea ion o a Type om a Da aType and ano he one ha s o es he c ea ion o a Table and a Column om a Class. Lis ing 1.2: Exce p o Class2Rela ional ans o ma ion 1 ule Da aType2Type { 2 om 3d : Class!Da aType 4 o 5ou : Rela ional!Type ( 6name <- d .name 7) 8} 9 10 11 ule Class2Table { 12 om c : Class!Class 13 o 14 ou : Rela ional!Table ( 15 name <- c.name, 16 key <- key), 17 key : Rela ional!Column ( 18 name <- ’objec Id’, 19 ype <- hisModule.objec IdType) 20 } Since hese wo aces a e ins an ia ions o he gene ic one shown in Figu e 2(a), we can also ins an ia e he MRs shown in Lis ing 1.1. In pa icula , we ha e wo scena ios. The i s one consis s o adding an elemen o ype Da aType in C2, wha yields he 284 © Ediciones Uni e sidad de Salamanca ja ie oya, se gio segu a, an onio uiz-co és owa ds he au oma ion o me amo phic es ing in model ans o ma ions XXI Jo nadas de Ingenie ía del So wa e y Bases de Da os, pp. 281-284 4 Towa ds he Au oma ion o Me amo phic Tes ing in Model T ans o ma ions MRs shown in Lis ing 1.3. In he second scena io we add an elemen o ype Class in C2, ob aining he MRs shown in Lis ing 1.4. Lis ing 1.3: MRs o he addi ion o a Da aType in C2 1T1_Type.allIns ances()->size()=T2_Type.allIns ances()->size()-1 2T1_Column.allIns ances()->size()=T2_Column.allIns ances()->size() 3T1_Table.allIns ances()->size()=T2_Table.allIns ances()->size() Lis ing 1.4: MRs o he addi ion o a Class in C2 1T1_Column.allIns ances()->size()=T2_Column.allIns ances()->size()-1 2T1_Table.allIns ances()->size()=T2_Table.allIns ances()->size()-1 3T1_Type.allIns ances()->size()=T2_Type.allIns ances()->size() 3 Nex S eps and Obse a ions In his pape we ha e gi en an insigh in o ou app oach o au oma e he gene a ion o MRs o MTs. We iden i y gene ic pa e ns in he aces, om which we de ine gene ic MRs o ganized as well in pa e ns. Fo ins ance, one pa e n is he gene ic ace and MRs we ha e shown in his pape . Despi e i s simplici y, we a e pe o ming ongoing wo ks de ining mo e pa e ns whe e elemen s, a ibu es and ela ionships a e aken in o accoun , so ha we end up wi h a la ge se o MRs. One o he pu poses o he gene a ed MRs is o au oma e eg ession es s, since hey can be checked as o whe he hey hold in di e en e sions o he model ans o ma ion p og am and o any es model. As men ioned, ou app oach akes as inpu one o mo e execu ions o a MT, i.e., he esul ing ace models. The numbe o execu ions o he MT ecei ed and hei size in luence he comple eness o he MRs gene a ed. Fo ins ance, i a ule is ne e applied in any o he execu ions ecei ed as inpu , no MRs will conside i s beha io . Acknowledgmen s. This wo k has been pa ially unded by he Eu opean Commission (FEDER) and Spanish Go . unde CICYT p ojec BELI (TIN2015-70560-R), and by he Andalusian Go . p ojec s THEOS (TIC-5906) and COPAS (P12- TIC-1867). Re e ences 1. Am ani, M., Lucio, L., Selim, G.M.K., Combemale, B., Dingel, J., Vangheluwe, H., T aon, Y.L., Co dy, J.R.: A idimensional app oach o s udying he o mal e i ica ion o model ans o ma ions. In: P oc. o ICST. pp. 921–928. IEEE (2012) 2. Gogolla, M., Vallecillo, A.: T ac able Model T ans o ma ion Tes ing. In: ECMFA. LNCS, ol. 6698, pp. 221–235. Sp inge (2011) 3. Jiang, M., Chen, T.Y., Kuo, F., Zhou, Z., Ding, Z.: Tes ing Model T ans o ma ion P og ams using Me amo phic Tes ing. In: SEKE’14. pp. 94–99 (2014) 4. Jouaul , F.: Loosely Coupled T aceabili y o ATL. In: Wo kshop P oc. o ECMDA (2005) 5. Segu a, S., F ase , G., Sanchez, A., Ruiz-Co es, A.: A su ey on me amo phic es ing. IEEE T ansac ions on So wa e Enginee ing (99), 1–1 (2016) 6. T oya, J., Vallecillo, A.: A Rew i ing Logic Seman ics o ATL. Jou nal o Objec Technology 10, 5:1–29 (2011) 7. Vallecillo, A., Gogolla, M., Bu gue˜ no, L., Wimme , M., Hamann, L.: Fo mal speci ica ion and es ing o model ans o ma ions. In: P oc. o SFM. LNCS, ol. 7320, pp. 399–437. Sp inge (2012)