adb命令行执行uiautomator2

命令行格式:

  adb shell am instrument -w -r [-e ] 执行器

获取instrumentation执行器

在命令行执行adb shell pm list instrumentation, 获取自己需要执行的instrumentation执行器

执行全部用例

  adb shell am instrument -w -r 执行器, adb shell am instrument -w -r com.haofenqi.myapplication04.test/androidx.test.runner.AndroidJUnitRunner

过滤器

  执行某一个类中的测试用例(-e class )

    adb shell am instrument -w -r -e class 全类名  com.haofenqi.myapplication04.test/androidx.test.runner.AndroidJUnitRunner

   执行某一个类下的某一个用例

    adb shell am instrument -w -r -e class 全类名#方法名  com.haofenqi.myapplication04.test/androidx.test.runner.AndroidJUnitRunner

  执行某一个包下全部用例

    adb shell am instrument -w -r -e package 包名  com.haofenqi.myapplication04.test/androidx.test.runner.AndroidJUnitRunner

  执行指定注解的用例

    adb shell am instrument -w -r -e annotation 注解名  com.haofenqi.myapplication04.test/androidx.test.runner.AndroidJUnitRunner

    执行自定义注解执行用例,自由度很高, 用例比较多,且执行逻辑比较复杂时, 可以使用自方法

    

原文地址:https://www.cnblogs.com/yaoqingzhuan/p/12554542.html