android的測試工具CTS

android的測試工具CTS

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


轉載出處:http://mehuping.blog.163.com/blog/static/136666644201062331228956/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章