The premise is that the jdk,android and ant environments are configured on their own computers.
1, under the command line into the \android-sdk\tools\ directory, run the command:
Android List
View the ID value of the SDK corresponding to Android version find your phone
Or the version that the simulator corresponds to
2, still under the \android-sdk\tools\ directory, run the command:
Android Create Uitest-project-n <name>-T <android-sdk-ID>-P <path>
Like what:
Android Create Uitest-project-n autorunner-t 60-p f:\uiautomator
Where Autorunner: is the name of the jar package to be generated
60: The ID value of the SDK that corresponds to the Android version of your phone or simulator version number
F:\uiautomator: Path of your own project (absolute path)
3. Enter the project directory under the command line and run the ant build, which will build the jar using ant build.
The jar file is then generated in the Bin directory.
4. Installation and operation
ADB push <jar file path > data/local/tmp
adb shell uiautomator runtest <jar file name >-C < class name in project, including package name >
Like what:
Installation: adb push F:\uiautomator\bin\AutoRunner.jar data/local/tmp
Where: F:\uiautomator\bin\AutoRunner.jar the full path of the jar package generated in the third step
DATA/LOCAL/TMP: Installation path for mobile phone or simulator
Run: adb shell uiautomator runtest autorunner.jar-c com. Runner
Where Autorunner.jar: The third step generates the jar package (not the full path)
Com.uiautomator.testcase.LaunchSettings: The full package name + class name of the class to run
Android Uiautomator Automated Testing