Model-Based Testing of Web Applications
Total Page:16
File Type:pdf, Size:1020Kb
RADBOUD UNIVERSITY NIJMEGEN MASTER THESIS COMPUTER SCIENCE MODEL-BASED TESTING OF WEB APPLICATIONS 26 May 2015 Author: J.R. Monsma, BSc Radboud University Student No. s4236777 Comeniuslaan 4 6525 HP Nijmegen Internal Supervisor: The Netherlands Dr. ir. G.J. Tretmans Faculty of Science Second Supervisor: Huygens building Dr. G. Gousios Heyendaalseweg 135 6525 AJ Nijmegen External Supervisor The Netherlands Ing. B. Duijs, MSc Abstract Software shifts more and more to the online world. Testing web applications requires documents that specify what their correct behaviour is. Lack of documentation for smaller web application makes testing difficult. In this study, we try to find a solution to test web application based on a model-based testing approach. We use model-based testing for detection failures in web applications, the differences between the behaviours of the System under Test(SUT) and what is expected based on the specification. We have chosen for the model-based testing approach because it automates the testing process, adapts quicker to changes, it is time saving, and less error prone if the system is modelled correctly. Using G∀ST as a model-based testing tool, we generate test cases based on the model of the web application. PhantomJS, a headless browser is used to access a web application. With an adapter, we established the communication with the model-based testing tool and the headless browser. The adapter communicate with sockets to the model-based testing tool and translate received input from the model-based testing tool to useable input for the SUT. To create a generic model that is capable to test different web applications, we assume that every web page is the same, based on its content. Each page can hold links, events, images, and Styling- and JavaScript code. Based on this abstraction we created a small model that is applicable to test many web applications without any changes to the model. This model clicks on links and check for content errors. We extended this model to test forms, based on three options. Testing results show that the model is generic and capable of testing different web application. However, larger applications the amount of pages tested decreases based on the random generation of test cases by G∀ST, pages are tested multiple times instead of testing undiscovered pages. Testing webshop applications, the model requires an extension to test features that occur in a webshop. Results show that the model does not suits itself to test different webshop applications. The checkout phase of a webshop differs and it is hard to model it to a generic solution. However, the functionalities of a webshop stays the same and there we have chosen to allow changes in the model. Testing results show we can add and buy products, but the same problem with hold with generating test cases. Based on testing two web applications with forms and two webshop applications we can say that we can improve quality of web applications with model-based testing. However, the improvement is not enormous. There is improvement required on the test selection by G∀ST. To increase the quality even further more quality characteristics can be used to test on. 1 Acknowledgments I would like to take this opportunity to thank the people that have helped me with this thesis. First, I would like to thank Jan Tretmans and Bard Duijs for their supervision and their clear view and thoughts about this topic. Furthermore, I would like to thank Bard Duijs and Laurens Alers for giving me the opportunity to write this thesis at Bluenotion. It was great to spar with you guys to get fresh new insights. I also want to thank you for giving me the freedom to sail my own course and tackle certain problems I faced. I would also like to thank the developers of Bluention for setting up a test environment and solving some internal problems we faced during testing of the use cases. I appreciated their opinions and insights on the topic and their advice on how to address a certain problem. I would like to thank Pieter Koopman for his help with the Model-based testing tool G∀ST. Lastly, I would like to thank my friends and family, especially for the refreshing coffee breaks and having someone to talk to, and my parents and girlfriend for the pep talks when I needed those. 2 Contents ABSTRACT ........................................................................................................................................................... 1 ACKNOWLEDGMENTS ..................................................................................................................................... 2 1 INTRODUCTION ....................................................................................................................................... 5 1.1 AREA OF ONLINE WEB APPLICATIONS ........................................................................................................... 5 1.2 PROBLEM STATEMENT ..................................................................................................................................... 6 1.3 RESEARCH QUESTIONS ..................................................................................................................................... 7 1.4 RESEARCH CONTEXT......................................................................................................................................... 9 1.5 RESEARCH METHOD ......................................................................................................................................... 9 1.6 THESIS OUTLINE ................................................................................................................................................ 9 2 RELATED WORK ................................................................................................................................... 10 3 BACKGROUND ....................................................................................................................................... 12 3.1 WEB APPLICATIONS ........................................................................................................................................ 12 3.1.1 Forms ...................................................................................................................................................................13 3.2 SOFTWARE TESTING ....................................................................................................................................... 16 3.3 MODEL-BASED TESTING ................................................................................................................................ 18 3.3.1 Modelling languages ....................................................................................................................................18 3.3.2 Labelled Transition System .......................................................................................................................18 3.3.3 Finite State Machine ....................................................................................................................................19 3.3.4 Extended State Machine .............................................................................................................................20 3.4 MODEL-BASED TESTING TOOLS .................................................................................................................... 22 3.4.1 Overview of tools ............................................................................................................................................22 3.4.2 Graphwalker ....................................................................................................................................................22 3.4.3 TorXakis .............................................................................................................................................................23 3.4.4 G∀ST ....................................................................................................................................................................23 3.5 CHOICE OF MODELLING LANGUAGE AND MODEL-BASED TESTING TOOL ............................................... 25 4 TEST ARCHITECTURE ......................................................................................................................... 27 4.1 OVERVIEW OF THE CURRENT SITUATION .................................................................................................... 27 4.2 OVERVIEW OF THE TEST ARCHITECTURE .................................................................................................... 28 4.3 CONTENT MANAGEMENT SYSTEM ............................................................................................................... 30 4.4 THE SYSTEM UNDER TEST ............................................................................................................................ 30 4.4.1 Routing Engine ...............................................................................................................................................30 4.4.2 Application models .......................................................................................................................................32 4.4.3 Views ....................................................................................................................................................................33 4.4.4 Controllers ........................................................................................................................................................33