SwiftHand is an automated Android GUI testing tool. The tool uses machine learning to learn a model of the target app during testing, uses the learned model to generate user inputs that visit unexplored states of the app, and uses the execution of the app on the generated inputs to refine the model.
The main purpose of the repository is to provide a working demo of the version of the SwiftHand tool submited to the OOPSLA'13 conference. The repository provides source code for both front-end (instrumentation) and back-end (test engine). Example applications to paly with are also included.
The document is assuming that your system is either Linux or OSX. If you are Windows user, we recommend to use a free virtuallization tool such as VirtualBox and Docker.
Before playing with SwiftHand, please make sure to install the Android SDK (ADK). You can download it from http://developer.android.com/sdk/index.html. We recommend to use ADK 4.1.2 or a higher version. After installing ADK, please make sure that you have following six files.
Please memo your guava.jar version (17.0 in the example), your build-tools version (21.0.3 in the example), and the path to the ADK root directory. We will need this information later.
The SwiftHand implementation works with JDK version 6 and 7, and we recommend to use JDK version 7. Please check the path to the JDK root directory. We will need this information later.
Maven (http://maven.apache.org) is a project management and comprehension tool. Any recent version of Maven 3 will work.
Clone the SwiftHand repository to your local disk. Following command will do the work.
git clone git@github.com:wtchoi/SwiftHand.git
Open build.sh.skeleton, a skeleton of the main build script. You will find out following four commented lines.
#export ADK_ROOT=""
#export JAVA_HOME=""
#export GUAVA_VERSION=""
#export DX_VERSION=""
Assign appropriate values to the variables and uncomment them. Once the editing is done, type the following commands:
cp build.sh.skeleton build.sh
chmod 700 build.sh
Now, it is the time to do the actual build.
./build.sh
If the build process is succesful, you will see two new files in the directory: inst.sh and test.sh. Voila!
Do following steps to create Android Vritual Device. The steps will create an emulator image.
You can find the official guideline about the emulator management from here: 'http://developer.android.com/tools/devices/managing-avds.html'.
We recommand following command to setup necessary environment variable:
<ADK_ROOT>/tools/emulator -avd <AVD_NAME> -wipe-data -dns-server 127.0.0.1
-wipe-data options it to start an emulator from the factory-reset state -dns-server 127.0.0.1 option is a trick to disabling internet access.
The tool can be executed using the test.sh script generaated by the build scipt. For example, to test dist/benchmark/mininote.modified.apk using SwiftHand with random seed 0 for 1 hour:
./test.sh dist/benchmark/mininote.modified.apk swift 3600 0 <OUTPUT_DIR>
Please replace
With a compiled front-end, you can instrument an apk file using the inst.sh script generated by the build script.
./inst.sh <TARGET.apk>
Please make sure to replace
TARGET.modified.apk is an instrumented application file. TARGET.modified.json is a text file containing an information about the target application. To run a test, the back end requires both files to be in a singles directory.
The SwiftHand tool follows BSD licnese. Please check the License.txt file for more details.