美文网首页移动测试
UIautomator 2.0 命令行启动

UIautomator 2.0 命令行启动

作者: 白天才痴 | 来源:发表于2015-11-26 16:41 被阅读3767次

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

相关文章

网友评论

  • 闷骚的程序员:现在 monkeyrunner 是不是逐渐被抛弃转 UiAutomator 了?我刚做个工具还是用 monkeyrunner 弄的,但是感觉很受限,很多状态无法确知,Python 里对 Java 的异常貌似无能为力,对 UI 的精确测试能力略弱。
    白天才痴:@壮哥不胖 uiautomator上手也很简单,就几个api,你有空可以试试
    闷骚的程序员:@白天才痴 擦~弄之前应该先问问你的
    白天才痴:@壮哥不胖 runner应该是很早以前的了,主流的自动化框架都是uiautomator或者instrument

本文标题:UIautomator 2.0 命令行启动

本文链接:https://www.haomeiwen.com/subject/xfddhttx.html