Effective Generation of GUI Tests with Inferred Macro Events

Effective Generation of GUI Tests with Inferred Macro Events

Monkey See, Monkey Do: Effective Generation of GUI Tests with Inferred Macro Events Markus Ermuth Michael Pradel Department of Computer Science Department of Computer Science TU Darmstadt, Germany TU Darmstadt, Germany [email protected] [email protected] ABSTRACT mouse, and filling text into a form. However, the complex- Automated testing is an important part of validating the ity of many GUI applications makes manual UI-level test- behavior of software with complex graphical user interfaces, ing difficult. For example, a complex client-side web ap- such as web, mobile, and desktop applications. Despite re- plication may consist of dozens of pages that each provide cent advances in UI-level test generation, existing approaches hundreds of events that a tester may trigger. Because ex- often fail to create complex sequences of events that repre- ploring such programs manually is difficult, automated test sent realistic user interactions. As a result, these approaches generation approaches have been proposed [26, 24, 27, 11, cannot reach particular parts of the application under test, 8, 42, 17, 35]. The basic idea is to generate sequences of UI which then remain untested. This paper presents a UI-level events that achieve high coverage or that trigger a particular kind of problem. Existing approaches include black-box ap- test generation approach that exploits execution traces of 1 human users to automatically create complex sequences of proaches, such as the popular Monkey runner for Android , events that go beyond the recorded traces. The key idea is which triggers random UI events, and white-box approaches, to infer so-called macro events, i.e., sequences of low-level UI which, e.g., symbolically analyze the programs code to find events that correspond to a single logical step of interaction, events worth triggering. such as choosing an item of a drop-down menu or filling and Despite recent advances in UI-level test generation, two submitting a form. The approach builds upon and adapts important challenges remain. First, deeply exploring a pro- well-known data mining techniques, in particular frequent gram often requires complex sequences of events. For ex- subsequence mining and inference of finite state machines. ample, consider a program that uses a drop-down menu to We implement the approach for client-side web applications connect pages to each other. To reach another page, a test and apply it to four real-world applications. Our results generator must move the mouse into the menu, wait until show that macro-based test generation reaches more pages, the menu appears, and then click on one of the menu items, exercises more usage scenarios, and covers more code within without interleaving other events that would hide the menu a fixed testing budget than a purely random test generator. again. Existing black-box approaches are unlikely to cre- ate such complex sequences because they are unaware of the semantics of the individual UI events. One approach would CCS Concepts be to enhance black-box approaches with domain knowledge •Software and its engineering → Software notations about the most common complex sequences of events. How- and tools; Software maintenance tools; ever, the large number of such sequences and their different implementations makes this approach difficult in practice. Existing white-box approaches are, in principle, able to iden- Keywords tify complex sequences of events that lead to not yet covered GUI testing, test generation, JavaScript, web applications behavior, but do not scale well to complex programs. Second, effective testing requires both realistic sequences of events, to explore the most common paths that users will 1. INTRODUCTION take, and unusual sequences of events, to uncover corner case Many programs, such as client-side web applications, mo- errors. For example, consider a program that asks the user bile applications, and classical desktop applications, inter- to fill and submit a form. Most users will fill data into each act with users through a graphical user interface (GUI). It part of the form and then click the submit button. Since is important to test such programs at the UI-level by trig- most existing test generators are oblivious of how realistic gering sequences of UI events, such as clicking, moving the a sequence of events is, they do not recognize this common Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed way of using such a form, and instead spend significant effort Permission to make digital or hard copies of all or part of this work for personal or for profit or commercial advantage and that copies bear this notice and the full citation on exploring behavior that may not be relevant in practice, classroom use is granted without fee provided that copies are not made or distributed onfor the profit first or page. commercial Copyrights advantage for components and that copies of this bear work this owned notice andby others the full than citation the such as filling in some data without ever submitting the author(s)on the first must page. be honored.Copyrights Abstracting for components with credit of this is permitted.work owned To by copy others otherwise, than ACM or form. republish,must be honored. to post on Abstracting servers or withto redistribute credit is permitted. to lists, requires To copy prior otherwise, specificor permission republish, and/orto post a on fee. servers Request or to permissions redistribute from to lists, [email protected]. requires prior specific permission and/or a We identify an important reason why existing test gener- fee.ISSTA Request ’16 Saarbrucken, permissions from Saarland, [email protected]. Germany ation approaches do not fully address these challenges: The Copyright is held by the owner/author(s). Publication rights licensed to ACM. c 2016 Copyright held by the owner/author(s). Publication rights licensed to ACM. granularity of events as seen by the test generator does not ISBNISSTA’16 xxx-xxxx-xx-xxx/xx/xx., July 18–20, 2016, Saarbrücken, Germany 1 DOI:ACM.xx.xxxx/xxxxxxx.xxxxxxx 978-1-4503-4390-9/16/07...$15.00 http://developer.android.com/tools/help/monkey.html http://dx.doi.org/10.1145/2931037.2931053 82 match the logical steps perceived by a user. For example, a (a) Screenshot: Menu header: user considers “go to another page via a drop-down menu” - mouseover: show menu or “fill and submit a form” as one logical event, whereas a test generator treats them as sequences of various UI events. Test generators that are unaware of such logical steps spend Menu items: - mouseover: highlight item, keep menu visible lots of effort in generating sequences of events that a user - click: select item might never trigger and that may not reach particular states - mouseout: unhighlight item of the program. This paper presents a UI-level test generation approach (b) Execution traces: that exploits execution traces of human users to automati- Trace1 Trace2 Trace3 cally create complex sequences of events that represent log- Event Element Event Element Event Element ical steps as perceived by a user. We call such sequences of UI events macro events. The key components of the pre- mouseover header mouseover header mouseover header sented approach infer macro events from given usage traces mouseover item mouseover item mouseover item click item mouseout item click item and apply the inferred macro events during test generation mouseout item mouseover item mouseout item to automatically create tests that trigger complex, realistic click item sequences of events. Because the approach can be combined mouseover item with other test generation approaches, such as random test- ing or guided testing, it preserves the benefits of these ap- (c) Inferred macro event: proaches while addressing the challenge of creating complex, 1 realistic sequences of events. A major challenge is to infer and represent macro events in mouseover mouseover mouseover a way that abstracts from the recorded usage trace. This ab- header header header straction helps the approach to summarize multiple slightly mouseover click mouseout 3 4 5 different usages into a single macro event and to apply a 2 item item item mouseover macro event beyond the situation from which it is inferred. item We address this challenge by combining and extending two mouseout data mining techniques, frequent subsequence mining and item inference of finite state machines (FSMs). For example, Figure 1: Motivating example. these techniques may infer a macro event that represents “go to another page via a drop-down menu” from usage traces of a menu in the Zurmo web application. Correctly using that use the menu to reach some pages and apply the macro the menu is crucial for effectively using the program. Even event to reach other pages. though choosing an item from the menu can be seen as one We implement the approach into an automated test gen- logical step, it consists of multiple independent UI events: erator for client-side web applications and evaluate it with Revealing the menu corresponds to a mouseover event on four widely used programs. Our results show that the ap- the menu header. Moving the mouse through the menu cor- proach can effectively infer macro events from usage traces responds to mouseover and mouseout events on the menu and that macro-based test generation improves upon ran- item list, which highlight the corresponding item and keep dom test generation. In particular, we find that the ap- the menu visible. Selecting a menu item corresponds to a proach increases the number of pages visited within a fixed click event on the item. testing budget by 69.6%, on average, and that it increases Usage scenarios that require complex sequences of events, the number of covered branches for three of the four pro- such as the example, pose a challenge for automated test grams.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 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