Android CTS (Compatibility Test Suite) introduction
来源:互联网 发布:重庆网络机柜cqwsjg 编辑:程序博客网 时间:2024/06/04 18:42
What is CTS?
Compatibility Test Suite is a command mode tool to run a series of test cases in Android. They published all CTS source codes from Eclair branch on January 2010.
git repository
http://android.git.kernel.org/?p=platform/cts.git;a=summary
How to run CTS in host machine?
$ cd $MYDROID
$ . build/envsetup.sh
$ make cts
(it would generate all test plans, packages, cases, result report format and then zip to a android-cts.zip file)
- Package CTS: out/host/linux-x86/cts/android-cts.zip
- cts make file: mydroid/build/core/tasks/cts.mk
- run cts program: mydroid/out/host/linux-x86/bin/cts
- test plans: mydroid/out/host/linux-x86/cts/android-cts/repository/plans
- test packages: mydroid/out/host/linux-x86/cts/android-cts/repository/testcases
- test results: mydroid/out/host/linux-x86/cts/android-cts/repository/results
- CTS program settings value: mydroid/cts/tools/utils/host_config.xml
run cts
$ cd $mydroid/out/host/linux-x86/bin/
$ ./cts
Screen would like this:
erin@midnight:~/eclair/mydroid/out/host/linux-x86/bin$ ./cts
Android CTS version 2.1_r1
cts_host > help
Usage: command options
Avaiable commands and options:
Host:
help: show this message
exit: exit cts command line
Plan:
ls --plan: list available plans
ls --plan plan_name: list contents of the plan with specified name
add --plan plan_name: add a new plan with specified name
add --derivedplan plan_name -s/--session session_id -r/--result result_type: derive a plan from the given session
rm --plan plan_name/all: remove a plan or all plans from repository
start --plan test_plan_name: run a test plan
start --plan test_plan_name -d/--device device_ID: run a test plan using the specified device
start --plan test_plan_name -t/--test test_name: run a specific test
start --plan test_plan_name -p/--package java_package_name: run a specific java package
start --plan test_plan_name -t/--test test_name -d/--device device_ID: run a specific test using the specified device
start --plan test_plan_name -p/--package java_package_name -d/--device device_ID: run a specific java package using the specified device
Package:
ls -p/--package: list available packages
ls -p/--package package_name: list contents of the package with specified name
add -p/--package root: add packages from root to repository
rm -p/--package package_name/all: remove a package or all packages from repository
Result:
ls -r/--result: list all result of sessions
ls -r/--result -s/--session session_id: list detail case result of a specified session
ls -r/--result [pass/fail/notExecuted/timeout] -s/--session session_id: list detail cases of a specified session by the specified result.
History:
history/h: list all commands in command history
history/h count: list the latest count records in command history
history/h -e num: run the command designated by 'num' in command history
Device:
ls -d/--device: list available devices
How to add test plan, test packages to CTS?
- Add test package name to cts.mk, it would generate apk file when we build cts.
- Add all source folder (includes src java files, Android.mk and its Manifest file) to mydroid/cts/tests/tests
- If you'd like to create a test plan for this test package. Modify this python script: mydroid/cts/tools/utils/buildCts.py
Adjust CTS program settings?
Modify $mydroid/cts/tools/utils/host_config.xml
- Number of tests executed between reboots. A value <= 0 disables reboots. (maxTestCount)
- Max size [tests] for a package to be run in batch mode. (maxTestInBatchMode)
- Max time [ms] between test status updates. (testStatusTimeoutMs)
- Max time [ms] from start of package in batch mode and the first test status update. (batchStartTimeoutMs)
- Max time [ms] from start of test in individual mode to the first test status update. (individualStartTimeoutMs)
- Timeout [ms] for the signature check. (signatureTestTimeoutMs)
- Timeout [ms] for package installations. (packageInstallTimeoutMs)
- Time to wait [ms] after a package installation or removal. (postInstallWaitMs)
Write your own testing package?
If you would like to write your own testing package, you may reference the Instrumentation Testing documentfrom Android porting guide. Also, you could reference the source codefrom few Android application, like Browser, Messages, Gallery, Email,Camera, Calculator....etc. You can build its test apk file and uploadit to device.
How to write test cases?
Eachinstrumentation test case is similar to an Android application with thedistinction that it starts another application. For example, have alook in the $MYDROID/packages/apps/Music directory.
- There should be a Makefile and an Android Manifest file
- Tests are located in $MYDROID/packages/apps/Music/tests.
- TheInstrumentation Test Runner is located atpackages/apps/Music/tests/src/com/android/music/MusicPlayerFunctionalTestRunner.java.
Build package apk file
erin@midnight:~/eclair/mydroid/packages/apps/Music/tests$ mm
Install: out/target/product/generic/data/app/MusicTests.apk
Install it to the device
erin@midnight:~/eclair/mydroid/packages/apps/Music/tests$adb install../../../../out/target/product/generic/data/app/MusicTests.apk
How to run test cases in device?
Running Tests
erin@midnight:~/$ adb shell pm list instrumentation
instrumentation:com.android.music.tests/.MusicPlayerStressTestRunner (target=com.android.music)
instrumentation:com.android.music.tests/.MusicPlayerFunctionalTestRunner (target=com.android.music)
instrumentation:com.android.music.tests/.MusicPlayerLaunchPerformance (target=com.android.music)
Theam command is a command-line interface to the ActivityManager. 'am' isused to start and instrument activities using the adb shell command, asshown in the snippet below:
> adb shell am
usage: am [start|instrument]
am start [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
[-c <CATEGORY> [-c <CATEGORY>] ...]
[-e <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> ...]
[-n <COMPONENT>] [-D] [<URI>]
am instrument [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>]
[-w] <COMPONENT>
For example, to start the Contacts application you can use
> adb shell am start -n com.google.android.contacts/.ContactsActivity
Eg. verify Music player launcher performance
erin@midnight:~/$ adb shell am instrument -w -r com.android.music.tests/.MusicPlayerLaunchPerformance
Eg. verify Music player stress test
erin@midnight:~/$ adb shell am instrument -w -r com.android.music.tests/.MusicPlayerStressTestRunner
Here is a video about running a cts test case by Android emulator!
(Original: http://i-miss-erin.blogspot.com/2010/04/android-cts-compatibility-test-suite.html)
- Android CTS (Compatibility Test Suite) introduction
- Android CTS (Compatibility Test Suite) introduction
- Android CTS (Compatibility Test Suite) introduction--Erin Yueh
- Android Compatibility Test Suite
- Using Android's Compatibility Test Suite
- Using Android's Compatibility Test Suite
- using android's compatibility test suite
- android官网译文《Compatibility Test Suite》-兼容性测试套件
- Android CTS Test
- android CTS test
- android CTS Test
- android CTS Test
- android CTS Test
- Android API Guides 之 Introduction(2) - Device Compatibility
- CTS test failed ----- android.graphics.cts.YuvImageTest#testCompressYuvToJpeg
- CTS test
- Android 4.0 CTS,GTS,ctsVerifier Test Step
- Android CTS Verifier Sensor Test Cases (1)
- shell脚本文件类型与字符串判断
- Android 应用程序窗体显示状态操作(requestWindowFeature()的应用)
- 什么是BI(Business Intelligence)
- 新浪微博与腾讯微博的开放平台比较 -- 从程序员的角度
- 什么是ETL
- Android CTS (Compatibility Test Suite) introduction
- MySQL互为主从配置
- 学习-使用 Android 和 XML 构建动态用户界面
- hibernate的Criteria Query[转]
- 从清除浮动(clear float)谈拥有布局(has layout)与块级格式化范围(block formatting context)
- .NET学习手记之:WPF--线程
- 反编译器 mocha
- How to add a test plan, package to Android CTS?
- 意外地调用了方法或属性访问