ModuleResultsAndMetricsForwarder

public class ModuleResultsAndMetricsForwarder
extends ResultAndLogForwarder

java.lang.Object
   ↳ com.android.tradefed.result.ResultForwarder
     ↳ com.android.tradefed.result.ResultAndLogForwarder
       ↳ com.android.tradefed.result.ModuleResultsAndMetricsForwarder


ResultAndLogForwarder 的擴充功能,可將額外的模組相關指標新增至測試結果。

摘要

公用建構函式

ModuleResultsAndMetricsForwarder(ITestInvocationListener... listeners)

公用方法

void setAttemptIsolation(CurrentInvocation.IsolationGrade isolation)

設定是否應將嘗試回報為隔離。

void setMarkTestsSkipped(boolean skip)

是否要將所有測試案例標示為略過。

void setModuleId(String moduleId)
void setTestMappingSources( testMappingSources)

設定要插入指標的測試對應來源。

void testEnded(TestDescription test, long endTime, testMetrics)

ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 的替代方案,可直接指定結束時間。

void testEnded(TestDescription test, testMetrics)

回報個別測試案例的執行結束時間。

void testFailed(TestDescription test, FailureDescription failure)

回報個別測試案例的失敗情形。

void testFailed(TestDescription test, String trace)

回報個別測試案例的失敗情形。

void testRunEnded(long elapsedTimeMillis, runMetrics)

Reports end of test run.

void testRunFailed(FailureDescription failure)

由於 FailureDescription 所述的失敗情形,報表測試執行作業無法完成。

void testRunFailed(String errorMessage)

由於發生嚴重錯誤,報表測試執行作業無法完成。

void testRunStarted(String runName, int testCount, int attemptNumber)

回報測試執行的開始時間。

void testRunStarted(String runName, int testCount, int attemptNumber, long startTime)

回報測試執行的開始時間。

void testStarted(TestDescription test, long startTime)

testStarted(com.android.tradefed.result.TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map)) 進行準確的評估。

void testStarted(TestDescription test)

回報個別測試案例的開始時間。

公用建構函式

ModuleResultsAndMetricsForwarder

public ModuleResultsAndMetricsForwarder (ITestInvocationListener... listeners)

參數
listeners ITestInvocationListener

公用方法

setAttemptIsolation

public void setAttemptIsolation (CurrentInvocation.IsolationGrade isolation)

設定是否應將嘗試回報為隔離。

參數
isolation CurrentInvocation.IsolationGrade

setMarkTestsSkipped

public void setMarkTestsSkipped (boolean skip)

是否要將所有測試案例標示為略過。

參數
skip boolean

setModuleId

public void setModuleId (String moduleId)

參數
moduleId String

setTestMappingSources

public void setTestMappingSources ( testMappingSources)

設定要插入指標的測試對應來源。

參數
testMappingSources

testEnded

public void testEnded (TestDescription test, 
                long endTime, 
                 testMetrics)

可直接指定結束時間的 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 替代方案。搭配 testStarted(com.android.tradefed.result.TestDescription, long) 使用,可準確測量。

參數
test TestDescription:識別測試

endTime long:測試結束時間,透過 System.currentTimeMillis() 測量

testMetrics :發出的指標 ERROR(/Map)

testEnded

public void testEnded (TestDescription test, 
                 testMetrics)

回報個別測試案例的執行結束時間。

如果未叫用 testFailed(TestDescription, FailureDescription),這項測試就會通過。也會傳回在測試案例執行期間可能發出的任何鍵/值指標。

參數
test TestDescription:識別測試

testMetrics :發出的指標 ERROR(/Map)

testFailed

public void testFailed (TestDescription test, 
                FailureDescription failure)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:識別測試

failure FailureDescriptionFailureDescription,說明失敗情形和相關情境。

testFailed

public void testFailed (TestDescription test, 
                String trace)

回報個別測試案例的失敗情形。

會在 testStarted 和 testEnded 之間呼叫。

參數
test TestDescription:識別測試

trace String:失敗的堆疊追蹤

testRunEnded

public void testRunEnded (long elapsedTimeMillis, 
                 runMetrics)

報告測試執行結束時間。

參數
elapsedTimeMillis long:裝置回報的經過時間 (以毫秒為單位)

runMetrics :在測試執行結束時回報的鍵/值組合

testRunFailed

public void testRunFailed (FailureDescription failure)

由於 FailureDescription 所述的失敗情形,報表測試執行作業無法完成。

參數
failure FailureDescriptionFailureDescription,說明失敗情形和相關情境。

testRunFailed

public void testRunFailed (String errorMessage)

發生嚴重錯誤,導致報表測試執行作業無法完成。

參數
errorMessage StringString,說明執行失敗的原因。

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber)

回報測試執行的開始時間。

參數
runName String:測試執行作業名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別同一個 runName 的不同嘗試,該 runName 會多次執行。attemptNumber 是以 0 為索引,每次執行新作業時都應遞增。舉例來說,如果測試細部重試 3 次,則在相同 runName 下應有 4 次執行作業,且 attemptNumber 為 0 到 3。

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                int attemptNumber, 
                long startTime)

回報測試執行的開始時間。

參數
runName String:測試執行作業名稱

testCount int:測試執行作業中的測試總數

attemptNumber int:訂單號碼,用於識別相同 runName 的不同嘗試,該 runName 會多次執行。attemptNumber 是以 0 為索引,每次執行新作業時都應遞增。舉例來說,如果測試細部重試 3 次,則在相同 runName 下應有 4 次執行作業,且 attemptNumber 為 0 到 3。

startTime long:跑步開始時間,透過 System.currentTimeMillis() 測量

testStarted

public void testStarted (TestDescription test, 
                long startTime)

testStarted(com.android.tradefed.result.TestDescription) 的替代方案,我們也會指定測試開始時間,並搭配 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map)) 進行準確的評估。

參數
test TestDescription:識別測試

startTime long:測試開始時間,透過 System.currentTimeMillis() 測量

testStarted

public void testStarted (TestDescription test)

回報個別測試案例的開始時間。舊版介面,建議盡可能使用 testStarted(com.android.tradefed.result.TestDescription)

參數
test TestDescription:識別測試