套件通常會含有多個測試模組,且可觸及大量 測試語料庫大小舉例來說,Android Compatibility Test Suite (CTS) 包含數百個模組和數十萬個測試案例。
由於隔離不佳或裝置進入不良狀態,大量測試可能會失敗。
套件重試功能可解決這些情況:您只需重試失敗的測試,而非整個套件,即可排除不穩定性和隔離不佳的問題。如果測試持續失敗,重試也會失敗。和 但真的發生問題
實作套件重試
重試結果的過程包括讀取先前的結果,以及重新執行先前的叫用作業。
導致重試作業的主介面為 ITestSuiteResultLoader
。
可讓您載入上一個結果和上一個指令列。
RetryRescheduler
接著使用這項資訊重新建立先前的指令,並填入一些篩選器,以便只重新執行先前失敗或未執行的測試。
套件重試範例:CTS
CTS 中的重試設定如下:
<configuration description="Runs a retry of a previous CTS session.">
<object type="previous_loader" class="com.android.compatibility.common.tradefed.result.suite.PreviousResultLoader" />
<test class="com.android.tradefed.testtype.suite.retry.RetryRescheduler" />
<logger class="com.android.tradefed.log.FileLogger">
<option name="log-level-display" value="WARN" />
</logger>
</configuration>
這項功能適用於擴充該套件的大多數套件,例如 VTS。
這使用以下程式碼叫用:
cts-tradefed run retry --retry <session>
在 CTS 控制台中列出先前的結果即可找到這個工作階段:
cts-tf > l r
Session Pass Fail Modules Complete Result Directory Test Plan Device serial(s) Build ID Product
0 2092 30 148 of 999 2018.10.29_14.12.57 cts [serial] P Pixel
系統會重新載入確切的原始指令,並使用額外的篩選器重新執行。也就是說,如果原始指令包含某些選項,這些選項也會在重試時一併執行。
例如:
cts-tradefed run cts-dev -m CtsGestureTestCases
由於我們要重試的命令只涉及 CtsGestureTestCases
,因此上述重試一律會綁定至 CtsGestureTestCases
。
為 CTS 樣式套件設定重試
先前的結果必須匯出為 proto 格式。必須新增:
<result_reporter class="com.android.compatibility.common.tradefed.result.suite.CompatibilityProtoResultReporter" />
這項設定必須新增至主指令的 XML 設定,結果會在結果資料夾中建立 test-record.pb
檔案。
接著,CTS 重試會從 test-record.pb
和現有 test_result.xml
的組合載入資料,以準備重試叫用。