使用Instrumentation命令测试cts apk

作者: android之子 | 来源:发表于2018-02-10 11:23 被阅读225次

最近在android tv的项目,我负责媒体相关模块,为了更好的调试cts,gts某个模块的测试用例,加快debug速度,可以用adb使用命令来测试单个用例。使用am Instrument命令来完成本地测试debug,不需要依赖cts的整个测试包环境。

首先说下instrument是什么,instrument为am命令的一个子命令。用于启动一个Instrumentation测试。首先连接手机或者模拟器,通过adb shell命令,进入shell层进行操作。其实他还有很多功能,比如我们应用可以通过使用instrument,注册hook到系统的框架中,具体以后有机会我整理下,今天我们就说明下命令使用。

命令格式:

 instrument [-r] [-e ] [-p ] [-w]         [--user | current]         [--no-window-animation] [--abi ]      
Start an Instrumentation.  Typically this target is in the     form / or only if there     is only one instrumentation. 

Options are:     

-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with  [-e perf true] to generate raw output for performance measurements.     

-e : set argument to .  For test runners a         common form is [-e [,...]].     

-p : write profiling data to      

-m: Write output as protobuf (machine readable)     

-w: wait for instrumentation to finish before returning.  Required for  test runners.   

 --user | current: Specify user instrumentation runs in;  current user if not specified.     

--no-window-animation: turn off window animations while running.     

--abi : Launch the instrumented process with the selected ABI. This assumes that the process supports the selected ABI

各项参数:

-r:以原始形式输出测试结果;该选项通常是在性能测试时与[-e perf true]一起使用。

-e name value:提供了以键值对形式存在的过滤器和参数。例如:-e testFile (运行文件中指定的用例);-e package (运行这个包中的所有用例)……  有十几种。 

-p file:将分析数据写入file。

-w:测试运行器需要使用此选项。-w / :和在测试工程的AndroidManifest.xml中查找,作用是保持adb shell打开直至测试完成。

--no-window-animation:运行时关闭窗口动画。

--useruser_id | current:指定仪器在哪个用户中运行;如果未指定,则在当前用户中运行。

命令使用:

测试提供以下步骤:

1.安装测试apk,比如adb installGtsMediaTestCases.apk

2.找到本机的测试用例:pm list Instrumentation

3.如果想测试整个包,使用命令:

am instrument  -w com.google.android.media.gts/android.support.test.runner.AndroidJUnitRunner

4.如果想单个某个case使用以下命令:

 am instrument -e -r class com.google.android.media.gts.WidevineYouTubePerformanceTests#testL1Cenc1080P60 -w com.google.android.media.gts/android.support.test.runner.AndroidJUnitRunner

测试通过的:

测试失败的:

class可以去掉#testL1Cenc1080P60就是测试整个类。

5.运行所有测试用例除了指定的类:adb shell am instrument -w -r -e notClass com.google.android.media.gts.WidevineYouTubePerformanceTests com.google.android.media.gts/android.support.test.runner.AndroidJUnitRunner

6.运行所有测试除了指定的用例:adb shell am instrument -w -r -e notClass com.google.android.media.gts.WidevineYouTubePerformanceTests#testL1Cenc1080P60 com.google.android.media.gts/android.support.test.runner.AndroidJUnitRunner

7.以上所有参数也可以通过标签配置在AndroidManifest文件,比如 ,通过shell命令 传入的参数将覆盖AndroidManifest文件中配置的参数。

相关文章

  • 使用Instrumentation命令测试cts apk

    最近在android tv的项目,我负责媒体相关模块,为了更好的调试cts,gts某个模块的测试用例,加快debu...

  • CTS问题分析5

    CTS/GTS问题分析5 问题初探 测试命令: run cts -m CtsDevicePolicyManager...

  • 3. CTS 注意事项

    CTS 注意事项 如果忘记命令,在cts-tf输入help 查看命令; 测试完成后测试报告存放目录:android...

  • CTS问题分析4

    CTS/GTS问题分析4 问题初探 测试命令:run cts -m CtsOsTestCases -t andr...

  • CTS问题分析14

    CTS/GTS问题分析14 由于测试手法不规范造成的cts-on-gsi无法retry的问题 问题初探 测试命令:...

  • GMS 关于Camera相关项测试问题汇总

    android 5.1 6.0 测试命令: run cts --package android.camera ...

  • CTS测试命令

    这篇文章我列了一下常用的CTS命令: 1.查看帮忙信息 help 2.退出终端 exit: 3.进行plan为te...

  • CTS问题分析10

    CTS/GTS 问题分析10 一个CTS框架自身引起的问题 问题初探 测试命令: run retry --retr...

  • 培训课程

    1.过google认证所以进行cts,ctsv,GMS测试 2.介绍了测试报告的报告样式和命令(cts-) 3环境...

  • CTS问题分析1

    CTS/GTS问题分析1 问题初探 测试命令: run gts -m GtsGmscoreHostTestCase...

网友评论

    本文标题:使用Instrumentation命令测试cts apk

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