命令行格式:
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
執行自定義注解執行用例,自由度很高, 用例比較多,且執行邏輯比較復雜時, 可以使用自方法