This will guide you through the steps to write your first uiautomator test using gradle as it build system.
What is gradle?
“Gradle combines the power and flexibility of Ant with the dependency
management and conventions of Maven into a more effective way to build.”
For more visit gradle page.
What is uiautomator?
“The uiautomator testing framework lets you test your user interface (UI)
efficiently by creating automated functional UI testcases that can be run
against your app on one or more devices.”
For more visit uiautomator page.
Java source code
Create a directory named bluetooth:
Create a java project layout:
$ cd bluetooth
$ mkdir -p src/main/java/com/github/wiliamsouza/bluetooth
Create a java file BluetoothTest.java with the following content:
Create a build.gradle with the following content:
Now lets configure the build system, Create a file gradle.properties containing:
- androidSdkHome – Point to the root directory of android SDK.
- androidSdkTarget – Is the target, points to a directory inside platforms.
- androidSdkBuildToolsDir – Location of dx program.
$ adb push dist/bluetooth.jar /data/local/tmp/
$ adb shell uiautomator runtest bluetooth.jar -c com.github.wiliamsouza.bluetooth.BluetoothTest