安卓CTS官方文檔之兼容性測試套件簡介

官方英文文檔原文:https://source.android.com/compatibility/cts-intro.html

Compatibility Test Suite 

兼容性測試套件

How does the CTS work?

CTS是如何工作的?



Figure 1. How to use CTS

圖1. CTS使用流程

The CTS is an automated testing harness that includes two major software components:

CTS是一套自動化測試套件,它主要包含了兩個軟件組件:

  • The CTS test harness runs on your desktop machine and manages test execution.

  • CTS測試套件(框架)運行在你的桌面機器上以管理測試執行

  • Individual test cases are executed on attached mobile devices or on an emulator. The test cases are written in Java as JUnit tests and packaged as Android .apk files to run on the actual device target.

  • 每個測試用例都是在掛載連接上主機的安卓移動設備或者模擬器上執行的。測試用例都是用Java編寫的Junit單元測試,並且這些測試用例會被打包成安卓的.apk文件來在真實目標機器上執行。

(天地會珠海分舵注:這個架構跟MonekeyRunner和Appium這兩個UI自動化測試框架非常相似,代碼控制端,也就是指導測試用例執行的策略都是在主機端實現的,當需要操作目標安卓設備如注入事件的時候就會發送命令請求運行在設備上的服務來進行處理)

Workflow 

工作流程


This section summarizes CTS setup. Please refer to the CTS User Manual for detailed instructions.

這一小節會對如何建立CTS測試進行概要說明。如果需要詳細的指導文檔的話請查看CTS用戶手冊

  1. Download the CTS and CTS media files. / 下載CTS兼容性測試套件和CTS兼容性測試媒體文件(天地會珠海分舵注:因爲有些兼容性API的測試需要設計媒體播放功能)

  2. Attach at least one device (or emulator) to your machine./ 把至少一個安卓設備(或者模擬器)連接到你的主機上面(天地會珠海分舵注:注意不僅僅是連上去,還要保證SDK等正確安裝,可以使用adb操作該設備)

  3. For CTS versions 2.1 R2 through 4.2 R4, set up your device (or emulator) to run the accessibility tests:/如果你的目標機器版本和對應所需要的CTS版本是2.1R2到4.2R4之間的話,請根據下面的步驟來先在你的目標機器(或模擬器)上配置運行輔助功能測試:

    1. adb install -r android-cts/repository/testcases/CtsDelegatingAccessibilityService.apk
    2. On the device, enable Settings > Accessibility > Accessibility > Delegating Accessibility Service/在目標設備上以下位置啓動設置項: 設置>輔助功能>Delegating Accessibility Service。

  4. For CTS 2.3 R4 and beyond, set up your device to run the device administration tests:/如果你的測試設備的安卓版本是2.3 R4以及以上的話,請根據下面步驟來運行設備管理測試:

    1. adb install -r android-cts/repository/testcases/CtsDeviceAdmin.apk
    2. On the device, enable the two android.deviceadmin.cts.CtsDeviceAdminReceiver* device administrators under Settings > Location & security > Select device administrators / 在你的設備上面的以下位置使能android.deviceadmin.cts.CtsDeviceReceiver* 這兩個設備管理器:設置>安全和隱私>設備管理器

      Note: Make sure the android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver stays disabled in the same menu. / 注意確保在同一界面上的 android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver是在關閉狀態的。

  5. For CTS 2.3 R12 and beyond, the CTS media files must be copied to the device's external storage. Check section 4.2 of the latest CTS manual for further details on copying these files: / 如果你使用的設備是安卓2.3 R12及以上版本,相應的CTS媒體測試文件必須拷貝到設備的外存(sd卡)上面。關於考本的詳情請查看最近的CTS手冊的4.2節:

    1. Unzip the CTS Media zip file. / 將CTS測試媒體文件解包。

    2. Run the following command. If no resolution is specified, the default maximum resolution of 480x360 is assumed: / 運行下面的命令。注意如果沒有指定分辨率的話,將會假定使用的是480x360這個最高默認分辨率:

      copy_media.sh [720x480|1280x720|1920x1080|all] [-s serial]
  6. Launch the CTS. The CTS test harness loads the test plan onto the attached devices. For each test in the test harness: / 運行CTS。CTS測試套件會把測試計劃加載到掛載上來的所有測試設備上。對於測試套件上的每一個測試:

    • The test harness pushes an .apk file to each device, executes the test through instrumentation, and records test results. / 測試套件會把該測試對應的一個.apk文件推送到目標測試設備上,然後通過instrumentation框架來運行該測試,並且會將測試結果記錄下來。

    • The test harness removes the .apk file from each device. / 測試套件最後會在每個測試設備上刪除掉該.apk文件。

  7. Once all the tests are executed, view the test results in your browser and use them to adjust your design. You can continue to run the CTS throughout your development process. / 一旦以上所有測試都執行完畢後,你就可以在你的瀏覽器上查看對應的測試結果並使用它們來審覈你的設計是否正確。你可以在你的整個開發過程中不停的運行CTS來驗證你的設計。

Types of test cases

測試用例類型


The CTS includes the following types of test cases:

CTS包含以下幾種測試用例:

  • Unit tests test atomic units of code within the Android platform; e.g. a single class, such as java.util.HashMap.

  • 單元測試:測試在安卓平臺中原子單元粒度的代碼。比如測試一個如java.util.HashMap的類。

  • Functional tests test a combination of APIs together in a higher-level use-case.

  • 功能測試:在一個更高層次的測試用例上面去測試APIs的組合

  • Reference application tests instrument a complete sample application to exercise a full set of APIs and Android runtime services.

  • 應用參照測試:往一個示例應用中注入instrumentation框架來驗證一整套APIs和安卓運行時服務

Future versions of the CTS will include the following types of test cases:

將來的CTS版本將會包含以下類型的測試用例:

  • Robustness tests test the durability of the system under stress.

  • 健壯性測試:測試目標系統在一定壓力下的可持久性

  • Performance tests test the performance of the system against defined benchmarks, for example rendering frames per second.

  • 性能測試:測試系統在既定的基準點下的性能,比如測試安卓的幀渲染率。

Areas Covered

覆蓋範圍


The unit test cases cover the following areas to ensure compatibility:

單元測試用例將覆蓋以下範圍來對兼容性做出保障

Area
範圍
Description 
描述
Signature tests
簽名測試
For each Android release, there are XML files describing the signatures of all public APIs contained in the release.
The CTS contains a utility to check those API signatures against the APIs available on the device. The results from
 signature checking are recorded in the test result XML file.
在每個發佈的安卓版本中,都會有一個XML文件來描述所有包含的公開API的簽名信息。
CTS包含有一個工具來檢查驗證該發佈版本的API簽名和目標設備上已有的API簽名。
簽名測試的測試結果會記錄在xml格式的測試報告文檔中。
Platform API Tests
平臺API測試
Test the platform (core libraries and Android Application Framework) APIs as documented in the SDK Class Index to ensure API correctness, including correct class, attribute and method signatures, correct method behavior,
 and negative tests to ensure expected behavior for incorrect parameter handling.
測試SDK文檔中Class Index指定的平臺(核心庫和安卓應用框架)APIs,包括測試類,
類成員屬性和方法簽名的正確性,類成員方法的正確性,
以及通過負面測試來保證在輸入參數出錯時的處理是符合預期的
Dalvik VM Tests
Dalvik VM測試
The tests focus on testing the Dalvik Executable Format.
該測試主要是關注Dalvik可執行格式的測試
Platform Data Model
平臺數據模型
The CTS tests the core platform data model as exposed to application developers through content providers, 
as documented in the SDK android.provider package: contacts, browser, settings, etc.
這類CTS測試用例測試的是平臺通過Content Provider組件暴露給應用開發者的核心數據模型,
這些數據模型在SDK的 android.provider 包中有相應的定義,比如:聯繫人,瀏覽器,設置,等等。
Platform Intents
平臺Intents
The CTS tests the core platform intents, as documented in the SDK Available Intents.
這類CTS測試用例測試的是平臺核心的Intens組件,這些是在SDK的Available Intents中進行定義的。
Platform Permissions
平臺權限
The CTS tests the core platform permissions, as documented in the SDK Available Permissions.
這類CTS測試用例測試的是平臺的權限控制,這些是在SDK的Available Permissions中進行定義的。
Platform Resources
平臺資源
The CTS tests for correct handling of the core platform resource types, as documented in the SDK Available
 Resource Types
. This includes tests for: simple values, drawables, nine-patch, animations, layouts, styles 
and themes, and loading alternate resources.
這類測試用例測試的是平臺的核心資源類型處理的正確性,
這些是在SDK的Available Resource Types中進行定義的。
這些測試用例測試的資源類型包含以下方面:簡單值類型,
可描繪資源類型,nine-patch資源類型,動畫資源類型,
佈局類型,風格資源類型以及主題資源類型和對可選資源的加載。
(天地會珠海分舵:後一句的翻譯不敢完全確定,如果有更好的翻譯版本的敬請提供,先謝過了)



作者

自主博客

微信

CSDN

天地會珠海分舵

http://techgogogo.com


服務號:TechGoGoGo

掃描碼:

©著作權歸作者所有:來自51CTO博客作者zhukev的原創作品,如需轉載,請註明出處,否則將追究法律責任

0

收藏

zhukev

117篇文章,3W+人氣,0粉絲

Ctrl+Enter 發佈

發佈

取消

0

分享
zhukev
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章