1. 什么是CTS
兼容性测试,手机设备需要通过Android的兼容性测试(CTS),以确保在android上开发的程序在手机设备上都能运行,才能使用android market

2. 下载及安装
git下载的源码里包含cts,位置在$ANDROID/cts目录下(android2.1以后版本)
如果没有也可以从此处下载git://android.git.kernel.org/platform/cts.git(源码70M左右)
编译
$ build/envsetup.sh
$ make cts
此时生成测试计划,测试包,测试用例,和测试报告生成的目录

3. 使用

a) 方法1:一般使用的方法
$ cts 注意如果用手机设备调试,用root权限执行
cts_host > ls --plan 列出所有plan
out/host/linux-x86/cts/android-cts/repository/plans中有plan的具体内容
cts_host > start --plan VM 运行某个plan
测试结果在out/host/linux-x86/cts/android-cts/repository/results目录下,用浏览器看时间目录下的xml文件即可
注意在改动cts后,还要make cts重新编译,若只在cts目录中编译不能生效
cts_host > ls -p 看当前可用的用例包
cts_host > start --plan Android -p android.app 只运行某个用例包,节约时间
cts_host > start --plan Android -p android.app -t android.app.cts.AlertDialogTest#testAlertDialog
只运行某个用例包中的某个用例

b) 方法2:遇到问题时方便调试的方法
$ adb install out/target/product/xxxx/data/app/SginatureTest.apk 安装某个用例包
$ adb shell pm list instrumentation pm用于管理package,看当前机器安装了什么用例
$ adb shell am instrument -w android.tests.sigtest/.InstrumentationRunner am用于管理activity 运行某一用例
$ adb shell am instrument -e class android.app.cts.AlertDialogTest#testAlertDialog -w com.android.cts.app/android.test/InstrumentationCtsTestRunner 单独运行一个小case
如果在一个时间很长的plan(如Android)中,某处错了,而错误信息又不全,需要单独跑一个小case,用-e指明class明就可以节约很多时间

4. 说明

a) bin/cts是一个脚本,它使用adb来测试,测试程序及测试用例由java语言编写

b) cts主函数为cts/tools/host/src/com/android/cts/TestHost.java

5. 参考
http://www.kandroid.org/android_pdk/instrumentation_testing.html

更多相关文章

  1. [Android][Android(安卓)Studio] *.jar 与 *.aar 的生成与*.aar
  2. Android(安卓)AsyncTask完全解析,带你从源码的角度彻底理解
  3. android 处理运行时改变 开发文档翻译
  4. Android数据存取之Databases
  5. 基于 Android(安卓)NDK 的学习之旅-----JNI LOG 打印(附源码)
  6. Android事件分发机制五:面试官你坐啊
  7. Android(安卓)如何进行js交互
  8. Android通过WebView与JS交互的全面方式
  9. Android逆向之旅---Android中的sharedUserId属性详解

随机推荐

  1. Android获取当前WiFi的MAC地址-适配所有
  2. cocos2dx android mac
  3. Android休眠唤醒机制简介(一)
  4. intentDemo_2
  5. android 短信发送
  6. android的ListView
  7. Android(安卓)UI 之时间与日期控件
  8. Android(安卓)复习笔记之图解Actionbar
  9. 在Ubuntu10.04上设置和下载android4.0源
  10. android SubscriptionInfo更新流程