uiautomator一般由adb shell调用,也可以在手机端使用runTime执行。使用 adb shell uiautomator helper可以查看到uiautomator所有的命令
uiautomator的执行测试用例的命令如下:
#adb shell uiautomator runtest $jar_name -c $test_class_or_method [options]
下面详细的说一下命令:
1、runtest
runtest是执行测试的关键命令,用来执行jar包的测试用例。
2、jar_name
用于指定需要执行的测试用例所在的jar包名称,使用相对路径(uiautomator的jar包放置在安卓手机的/data/local/tmp/目录下),可以多指定jar包。
(1)若只存在一个测试jar包 A.jar,命令如下:
#adb shell uiautomator runtest A.jar -c $test_class_or_method [options]
(2)若 A.jar 测试过程中引入了第三方的jar包 B.jar ,则并列写,中间使用空格分隔即可,命令如下:
#adb shell uiautomator runtest A.jar B.jar -c $test_class_or_method [options]