Model-Driven Testing in Umple
Total Page:16
File Type:pdf, Size:1020Kb
Model-Driven Testing in Umple Sultan Eid A. Almaghthawi A thesis submitted in partial fulfillment of the requirements for the degree Ph.D in Computer Science Ottawa-Carleton Institute for Computer Science School of Electrical Engineering and Computer Science University of Ottawa Ottawa, Ontario, Canada April 2020 © Sultan Eid A. Almaghthawi, Ottawa, Canada, 2020 Acknowledgement Firstly, I would like to express my sincere gratitude to my supervisor Prof. Timothy Lethbridge for the continuous support of my Ph.D study and related research, for his patience, motivation, and immense knowledge. His guidance helped me in all the time of research and writing of this thesis. I could not have imagined having a better advisor and mentor for my Ph.D study. Besides my advisor, I would like to thank the rest of my thesis committee: Prof. Thomas R. Dean, Prof. Daniel Amyot, Prof. jean-Pierre Corriveau, and Prof. Stéphane Somé, for their insightful comments and encouragement, but also for the hard question which incented me to widen my research from various perspectives. Thanks to my country who had provided all the support needed and has always looked after its students. Also, thank you Taibah University for giving me the opportunity to pursue my study and providing the support needed especially professor Mosaed Alsobhe for his great insight and support during my early years as an academic. I also would like to thank everyone in the The Complexity Reduction in Software Engineering (CRUISE). All the discussion, brainstorming and code sprints we had over the years made this work possible. Last but not least, I would like to thank my family: Thank you and much love my wife Lamia; your endless support during the endeavor is forever appreciated. Thanks to my parents Fann and Eid for everything, may my father soul rest in peace, words cannot describe how gratefully I am for everything they have provided. Thanks to my brothers and sisters for supporting me spiritually throughout writing this thesis and my life in general. ii Abstract In this thesis we present a language and technique to facilitate model-based testing. The core of our approach is an xUnit-like language that allows tests to refer to model entities such as associations. This language can be used by developers to describe tests based on an existing UML model. The tests might even be written before creating a UML model, and be based on requirements. The testing language, including its parser and generators, is written entirely in Umple, an open-source textual modeling tool with semantics closely based on UML, and which generates Java, PHP and several other target languages. Tests in our language can be embedded in Umple or in standalone files. The test language compiler converts our abstract testing language into JUnit, PHPUnit and other domain-language testing environments. In addition to allowing developers to write tests manually, we have created generators that create abstract tests for any Umple model. These generators can be used to verify the Umple compiler and to give Umple users extra confidence in their models. User-defined tests can be standalone or embedded in methods; they can be generic, referring to metamodel elements. Tests can also be located in traits or mixsets to allow testing of separate concerns or product lines. To test our language and the tests written in it, we have created an extensive test suite. We have also implemented mutation testing, that enables varying of features of the models to ensure that runs of the pre-mutation tests then fail. iii Table of Contents Chapter 1 Introduction ........................................................................................................... 1 1.1 Thesis Topic and Contributions .................................................................................. 1 1.2 Problem Statement ...................................................................................................... 3 1.3 Motivation and Benefits .............................................................................................. 3 1.4 Methodology: Design Science .................................................................................... 5 1.5 Research Questions ..................................................................................................... 7 1.5.1 RQ1: What would be an effective syntax and semantics for an abstract model- level test language for testing UML class models? ................................................................. 7 1.5.2 RQ2: How can we evaluate the quality of the test specifications and the automatically generated tests? ................................................................................................. 8 1.6 Thesis Outline ............................................................................................................. 8 Chapter 2 Background............................................................................................................ 9 2.1 Software Testing ......................................................................................................... 9 2.2 Model-Based Testing ................................................................................................ 10 2.2.1 What is Model-Based Testing? ......................................................................... 10 2.2.2 Why Model-Based Testing? ............................................................................. 11 2.2.3 Where are the Weaknesses of Model-Based Testing? ...................................... 11 2.2.4 The Difference Between Model-Based and Model-Driven .............................. 13 2.2.5 Is Our Approach Offline-Testing or Online-Testing? ...................................... 14 2.3 Overview of Umple................................................................................................... 14 2.3.1 Umple Features Relevant to This Thesis: Mixins, Traits and Mixsets ............. 17 2.4 Model-Based Testing Tools and Technologies......................................................... 17 2.4.1 Conformiq Designer/Creator, Previously Known as Leirios ............................ 18 2.4.2 MBTestSuite ..................................................................................................... 18 2.4.3 MoMuT::UML .................................................................................................. 19 iv 2.4.4 RT-Tester and RTT-MBT ................................................................................. 20 2.4.5 TTCN-3 and UTP ............................................................................................. 20 2.4.6 ETSI Test Description Language ...................................................................... 22 2.4.7 Spec Explorer / PyModel .................................................................................. 22 2.4.8 ACL Contracts .................................................................................................. 22 2.4.9 MaTeLo............................................................................................................. 23 2.4.10 ModelJUnit / GraphWalker............................................................................... 23 2.5 Other Techniques That Are Related ......................................................................... 24 2.5.1 Aspect-Oriented Programming ......................................................................... 24 2.5.2 Generative Programming .................................................................................. 25 2.6 Summary ................................................................................................................... 25 Chapter 3 Basics of Model-Based Testing in Umple ........................................................... 27 3.1 Umple’s Model-Based Testing Architecture ............................................................ 29 3.2 Model Transformations in Our Approach................................................................. 30 3.3 The Umple Test Model Parser .................................................................................. 32 3.4 Testing of Attributes ................................................................................................. 37 3.4.1 Testing Lazy Attributes..................................................................................... 39 3.4.2 Testing Immutable Attributes ........................................................................... 40 3.5 Testing Associations ................................................................................................. 41 3.5.1 Optional-One to Many Associations ................................................................. 44 3.5.2 One to Many Associations ................................................................................ 46 3.5.3 N to Many Associations Where N Is a Fixed Number > 1 .............................. 48 3.5.4 Directional Associations ................................................................................... 50 3.5.5 Lower-Bounded and Upper-Bounded Associations: N..N -- * ......................... 52 3.5.6 Immutable Unidirectional Associations ............................................................ 54 v 3.5.7 Sorted Association in Umple ............................................................................ 56 3.5.8 Chained Associations ........................................................................................ 57 3.5.9 Reflexive Associations.....................................................................................