UIautomator 2.0 命令行启动

UIautomator2.0 由于牛逼闪闪的结合了instrumentation,不再是一个jar包,当然也不能通过之前的runtest命令启动了

不过既然使用了instrumentation,那么当然是通过instrument的方式启动了。

在2.0之前,我们通过命令行启动的方法是


adb shell am instrument -w com.android.demo.app.tests/android.test.InstrumentationTestRunner

在2.0里,instrument的runner变成了android.support.test.runner.AndroidJUnitRunner

所以,只需要替换原来的runner就可以运行uiautomator2.0的单元测试了


adb shell am instrument -w com.android.demo.app.tests/android.support.test.runner.AndroidJUnitRunner

使用命令行主要是在做持续集成时会用到.
另外,执行单独的case时直接用-e class +类名就行

adb shell am instrument -e class UnitTest -w com.android.demo.app.tests/android.support.test.runner.AndroidJUnitRunner

你可能感兴趣的:(UIautomator 2.0 命令行启动)