Graphical user interface test case generation for android apps using Q-learning / Husam N. S. Yasin - Husam , N. S. Yasin (2021)
Software testing is an effective means for assuring the quality of applications. Android applications (or mobile apps) have become an essential part of our daily life. Statistics affirm that 85% of smartphones worldwide are Android-based. Unfortunately, 17% of Android apps are still considered low-quality apps due to app crashes that can be avoided through intensive and extensive testing. Recently, Graphical User Interface (GUI) testing of Android app has gained considerable interest from the industries and research community due to its excellent capability to verify the operational requirements of GUI components. In the related literature, GUI test generation tools focus on generating tests and exploring app functions using different approaches. These tools are used to make the testing process more effective by finding faults; more comprehensive by achieving better code coverage and faster by producing the smallest possible event sequences. However, a common limitation of these tools is the low code coverage because of the tools' inability to find the right combination of actions that can drive the application into new and important states. Exploring the app's state extensively requires long event sequences to find the correct combination of actions, leading to excessively long transitions and wasted time. Such tools must choose not only which user interface element to interact with, but also which type of action to be performed to increase the percentage of code coverage and to detect faults with a limited time budget. This research addresses the problem of generating an effective test for Android apps that maximizes the instruction, method, and activity coverage by minimizing redundant execution of events. Hence, it proposes a Q-Learning-based test coverage approach developed in DroidbotX to generate GUI test cases for Android apps. It is a fully automated black-box testing approach that uses Upper Confidence Bound (UCB) exploration-exploitation strategy to generate actions that visit unexplored states of the app and uses the execution of the app on the generated actions to construct a state-transition model. Instead of randomly selecting the inputs, the test generator learns how to act in an optimal way that explores new states by using new actions to gain more rewards. Thus, the never selected actions can present a higher reward when compared to already executed actions. This reduces the redundant execution of events and increases coverage. The overall performance of DroidbotX was compared to five state-of-the-art test generation tools on 30 Android apps. DroidbotX achieved 51.5% accuracy for instruction coverage, 57% for method coverage, and 86.5% for activity coverage. It triggered 18 crashes within the time limit and shortest event sequence length compared to the other tools. The results demonstrate that the adaptation of Q-Learning with UCB exploration can significantly improve the effectiveness of the generated test cases. The computation time complexity of the Q-Learning-based test coverage algorithm was also analyzed. The results showed that time complexity was reduced significantly from