eclipse调试Cts 单项

        Cts测试中,单项失败是常用的事情,想要查找原因却比较麻烦,因为cts的command line 虽然提供了单项单独测试的方法,却只会输出结果,最多也就保留了device和host的log,用eclipse来调试还是比较不常见的。今天想到了这个麻烦,研究了下eclipse 调试Cts单项的方法:

        首先,Cts的测试主要还是要依赖apk,所以它的调试还是和app的调试很类似的。

1. 通过Cts command line 单独测试一下失败项,从log给出的信息中找到对应的apk。

2. Install这个apk,想办法让它跑起来,如果有activity,那am start 就好了。

3. 如果没有activity 只有instrumentation,那就要用am instrument,这个命令不太常用


am instrument: start an Instrumentation.  Typically this target <COMPONENT>
  is the form <TEST_PACKAGE>/<RUNNER_CLASS>.  Options are:
    -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with
        [-e perf true] to generate raw output for performance measurements.
    -e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners a
        common form is [-e <testrunner_flag> <value>[,<value>...]].
    -p <FILE>: write profiling data to <FILE>
    -w: wait for instrumentation to finish before returning.  Required for
        test runners.
    --user <USER_ID> | current: Specify user instrumentation runs in;
        current user if not specified.
    --no-window-animation: turn off window animations while running.
    --abi <ABI>: Launch the instrumented process with the selected ABI.
        This assumes that the process supports the selected ABI.


说明不是很清楚,大概可以看出可以通过 am instrument -r -w XXX 一个instrumentation的名字来跑这个instrumentation。

如何跑单项呢? 要用到-e 

例如:

am instrument -r -e class android.provider.cts.MediaStore_FilesTest#testAccess -w com.android.cts.provider/android.support.test.runner.AndroidJUnitRunner


android.provider.cts.MediaStore_FilesTest#testAccess 这一串是不是很熟悉呢,对了,就是cts单项测试时候打印出来的东东,包名类名加方法名。

com.android.cts.provider/android.support.test.runner.AndroidJUnitRunner 这一串呢就是instrumentation的名字,咋知道呢?AndroidManifest里有。

通过pm list instrumentation 也可以查出来。


ok,只要能让这个apk跑起来就好办了,eclipse就可以attach来调试咯。

找个时机去attach也是关键,这里就可以用am set-debug-app来创造时机了。这是一个很有内涵的命令,找个时间再来分析了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值