GUI-based testing has been primarily used to examine the functionality and usability of mobile apps. Despite the numerous GUI-based test input generation techniques proposed in the literature, these techniques are still limited by (1) lack of context-aware text inputs; (2) failing to generate expressive tests; and (3) absence of test oracles. To address these limitations, we propose CraftDroid, a framework that leverages information retrieval, along with static and dynamic analysis techniques, to extract the human knowledge from an existing test suite for one app and transfer the test cases and oracles to be used for testing other apps with the similar functionalities. Evaluation of CraftDroid on real-world commercial Android apps corroborates its effectiveness by achieving 73% precision and 90% recall on average for transferring both the GUI events and oracles. In addition, 75% of the attempted transfers successfully generated valid and feature-based tests for popular features among apps in the same category.
Python 3.6, with the following packages installed:
Appium-Python-Client, beautifulsoup4, Flask, Flask-RESTful, gensim, html5lib, lxml, numpy, requests, scipy, selenium
Tested on Android Studio 3.4 / Nexus_5X Emulator w/ API_23 (x86_64 image) / Windows 10
Download the subject apks, and our implementation of CraftDroid as well as the test cases for the subject apps
Install subject apps on the emulator; we suggest starting with the apps under a2-todo/ to avoid some network issues of apps
Start the emulator; Start Appium-desktop
Run word2vec_service.py first to activate the background web service for similarity query (modify the path in source code pointing to GoogleNews-vectors-negative300.bin)
Run Explorer.py with arguments:
python3 Explorer.py ${TRANSFER_ID} ${APPIUM_PORT} ${EMULATOR}
TRANSFER_ID is the transfer id, APPIUM_PORT is the port used by Appium-Desktop (4723 by default), EMULATOR is the name of the emulator, e.g.,
python3 Explorer.py a21-a22-b21 4723 emulator-5554
It will start transferring the test case of a21-Minimal to a22-Clear List for the b21-Add task function.
5. The source test cases are under test-repo/[CATEGORY]/[FUNCTIONALITY]/base/[APP_ID].json, e.g., test-repo/a2/b21/base/a21.json. The generated test cases for the target app is under generated/[APP_FROM]-/[APP_TO]-[FUNCTIONALITY].json, e.g., test-repo/a2/b21/generated/a21-a22-b21.json