am instrument 命令详解运行多个用例
1 Instrument是什么?
instrument为am命令的一个子命令。用于启动一个Instrumentation测试。首先连接手机或者模拟器,通过adb shell命令,进入shell层进行操作。
2 命令格式及参数解读(来自官网)
格式:instrument [options] component
目标 component是表单 test_package/runner_class,
在UiAutomator2.0中,目标 component为:测试包名/android.support.test.runner.AndroidJUnitRunner,
(即运行器固定:AndroidJUnitRunner类是一个JUnit测试运行器,允许运行JUnit 3或JUnit 4测试类在 Android 设备上,包括那些使用Espresso和UI Automator框架。)
各项参数:
-r:以原始形式输出测试结果;该选项通常是在性能测试时与[-e perf true]一起使用。-e name value:提供了以键值对形式存在的过滤器和参数。例如:-e testFile <filePath>(运行文件中指定的用例);-e package <packageName>(运行这个包中的所有用例)…… 有十几种。-p file:将分析数据写入file。-w:测试运行器需要使用此选项。-w <test_package_name>/<runner_class> :<test_package_name>和<runner_class>在测试工程的AndroidManifest.xml中查找,作用是保持adb shell打开直至测试完成。--no-window-animation:运行时关闭窗口动画。--user user_id | current:指定仪器在哪个用户中运行;如果未指定,则在当前用户中运行。
3 怎么运行手机中现有的instrumentation, 并输出详细结果,同时将profiling性能数据写到本地文件中?
- 先列出手机中已安装的instrumentation:adb shell pm list instrumentation
- adb shell am instrument XXX
4 命令的具体使用,比如com.le.tcauto.uitest.test是包含所有测试代码的应用的包名:(来自:http://blog.csdn.net/swordgirl2011/article/details/50881390)
- 运行所有的用例: adb shell am instrument -w com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行一个类中的所有用例:adb shell am instrument -w -r -e class com.letv.leview.setproxy com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行类中的某个方法:adb shell am instrument -w -r -e debug false -e class com.letv.leview.setproxy#testDemo com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行多个类的所有用例:adb shell am instrument -w -r -e debug false -e class com.letv.leview.setproxy,com.letv.leview.resetdate com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行所有测试用例除了指定的类:adb shell am instrument -w -r -e notClass com.letv.leview.setproxy com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行所有测试除了指定的用例:adb shell am instrument -w -r -e debug false -e class com.letv.leview.setproxy#testDemo com.le.tcauto.uitest.test/android.support.test.runner.AndroidJUnitRunner
- 运行文件中的所列的用例:adb shell am instrument -w -e testFile /sdcard/tmp/testFile.txt com.android.foo/com.android.test.runner.AndroidJUnitRunner 文件制定的 格式为:com.android.foo.FooClaseName#testMethodName
- 运行指定测试切片的用例:adb shell am instrument -w -e numShards 4 -e shardIndex 1 com.android.foo/android.support.test.runner.AndroidJUnitRunner
- 运行指定注解的测试用例:adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.support.test.runner.AndroidJUnitRunner。如果使用多个选项,则运行的用例为两者的交集,比如:“-e size large -e annotation com.android.foo.MyAnnotation”,将只运行同时含LargeTest和MyAnnotation注解的用例。
- 运行没有指定注解的用例:adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.support.test.runner.AndroidJUnitRunner,指定多个注解,用“,”隔开,e.g. adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation com.android.foo/android.support.test.runner.AndroidJUnitRunner
- 以上所有参数也可以通过<meta-data>标签配置在AndroidManifest文件,比如 <meta-data android:name="listener" android:value="com.foo.Listener"/>,通过shell命令 传入的参数将覆盖AndroidManifest文件中配置的参数。
5 开始容易写错?
AS ——Select Run/Debug —— Configuration ——Edit Configuration ——配置 ——OK
运行完成,下方会显示该命令,然后copy过来。
am instrument 命令详解运行多个用例的更多相关文章
- 【Devops】【docker】【CI/CD】关于jenkins构建成功后一步,执行的shell命令详解+jenkins容器运行宿主机shell命令的实现方法
1.展示这段shell命令 +详解 #================================================================================= ...
- linux yum命令详解
yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器.基於RPM包管理,能够从指定的服务器自动下载RP ...
- Linux下ps命令详解 Linux下ps命令的详细使用方法
http://www.jb51.net/LINUXjishu/56578.html Linux下的ps命令比较常用 Linux下ps命令详解Linux上进程有5种状态:1. 运行(正在运行或在运行队列 ...
- Docker命令详解
Docker命令详解 最近学习Docker,将docker所有命令实验了一番,特整理如下: # docker --help Usage: docker [OPTIONS] COMMAND [arg ...
- android adb 命令详解
ADB (Android Debug Bridge) 是android SDK中的工具,需要先配置环境变量才能使用.起调试桥的作用,可以管理安卓设备.(也叫debug工具) ---------查看设 ...
- Git 常用命令详解
Git 是一个很强大的分布式版本管理工具,它不但适用于管理大型开源软件的源代码(如:linux kernel),管理私人的文档和源代码也有很多优势(如:wsi-lgame-pro) Git 的更多介绍 ...
- Top 命令详解
Top 命令详解 先感受一下top命令的执行结果吧!哈哈-- top - 17:32:34 up 3 days, 8:04, 5 users, load average: 0.09, 0.12, 0. ...
- DOS命令详解
DOS命令详解 命令 \? 可以进入命令帮助 1.md命令创建目录. MKDIR [drive:]pathMD [drive:]path 如果命令扩展被启用,MKDIR 会如下改变: 如果需要,MKD ...
- Linux上的free命令详解、swap机制
Linux上的free命令详解 解释一下Linux上free命令的输出. 下面是free的运行结果,一共有4行.为了方便说明,我加上了列号.这样可以把free的输出看成一个二维数组FO(Free ...
随机推荐
- 微信小程序的模板消息与小程序订阅消息
小程序订阅消息 功能介绍 消息能力是小程序能力中的重要组成,我们为开发者提供了订阅消息能力,以便实现服务的闭环和更优的体验. 订阅消息推送位置:服务通知 订阅消息下发条件:用户自主订阅 订阅消息卡片跳 ...
- BS项目启动任意EXE文件或者CS项目
1. 基于注册表启动exe程序 1. 桌面新建注册表执行文件:protocal.reg 2. 任意文本编辑器打开该文件 Windows Registry Editor Version 5.00 [HK ...
- mysql的varchar和oracle的varchar2、nvarchar2
mysql的varchar长度表示字符长度,一个汉字和一个英文字母的长度都是1 实例:下面name字段定义为varchar(10),可存10个汉字和10个字母 oracle的varchar2长度表示的 ...
- Spring IOC 常用的注解
一.@Bean 1.配置类 @Configuration public class MainConfig { @Bean public Person person(){ return new Pers ...
- 查看linux中某个端口port是否被利用
(1)lsof -i:端口号查看某个端口是否被占用 (2)netstat -an|grep 80 netstat -- show network status (3)杀掉进程 kill pid 注意: ...
- linux写shell注意的问题
linux写shell注意的问题一定要vi crontab.sh来写 ps:在windows系统中编辑过这个文件,就会出现类似的换行符 这样导致linux系统中运行sh报错 比如会出现$MQ字符 如果 ...
- MyBatis 通过 BATCH 批量提交
本文由 简悦 SimpRead 转码, 原文地址 https://www.jb51.net/article/153382.htm 很多人在用 MyBatis 或者 通用 Mapper 时,经常会问有没 ...
- notepad++格式化代码,自动对齐
Notepad++本身没有快捷命令格式化JavaScript代码,需要通过安装扩展插件来实现快捷格式化JS代码的功能.本文主要介绍如何通过安装JStool插件来实现格式化JS代码的功能. 在插件列表中 ...
- WPF 精修篇 路径动画
原文:WPF 精修篇 路径动画 路径动画 是让一个对象围绕指定Path 的运动路径 进行移动的动画 举栗子 路径动画 使用 Blend 来设置 是十分简单的 首先用工具 笔 点出一条线 新建一个圆形 ...
- SQL 复制表到另一个表
SqlServer 复制表结构和表数据 复制表数据到已存在的表 INSERT INTO targetTableName SELECT COLUMNS FROM sourceTableName; 复制表 ...