結果轉發器
public class ResultForwarder
extends Object
implements ITestInvocationListener
java.lang.Object | |
↳ | com.android.tradefed.result.ResultForwarder |
將調用結果轉發到其他偵聽器列表的ITestInvocationListener
。
概括
公共構造函數 | |
---|---|
ResultForwarder ( listeners) ResultForwarder ( listeners) 創建一個 | |
ResultForwarder ( ITestInvocationListener... listeners) |
受保護的構造函數 | |
---|---|
ResultForwarder () 創建具有延遲偵聽器設置的 |
公共方法 | |
---|---|
TestSummary | getSummary () 允許 InvocationListener 返回摘要。 |
void | invocationEnded (long elapsedTime) 報告調用已終止,無論是成功還是由於某些錯誤條件。 |
void | invocationFailed ( FailureDescription failure) 由於某些錯誤情況,報告不完整的調用。 |
void | invocationFailed (Throwable cause) 由於某些錯誤情況,報告不完整的調用。 |
void | invocationStarted ( IInvocationContext context) 報告測試調用的開始。 |
void | testAssumptionFailure ( TestDescription test, String trace) 當原子測試標記它假定條件為假時調用 |
void | testAssumptionFailure ( TestDescription test, FailureDescription failure) 當原子測試標記它假定條件為假時調用 |
void | testEnded ( TestDescription test, long endTime, testMetrics) testEnded ( TestDescription test, long endTime, testMetrics) 替代 |
void | testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics) 報告單個測試用例的執行結束。 |
void | testFailed ( TestDescription test, FailureDescription failure) 報告單個測試用例的失敗。 |
void | testFailed ( TestDescription test, String trace) 報告單個測試用例的失敗。 |
void | testIgnored ( TestDescription test) 當測試不會運行時調用,通常是因為測試方法使用 org.junit.Ignore 註釋。 |
void | testLog (String dataName, LogDataType dataType, InputStreamSource dataStream) 提供來自測試調用的關聯日誌或調試數據。 |
void | testModuleEnded () 報告模塊運行的結束。 |
void | testModuleStarted ( IInvocationContext moduleContext) 報告正在運行的模塊的開始。 |
void | testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics) 報告測試運行結束。 |
void | testRunFailed ( FailureDescription failure) 由於 |
void | testRunFailed (String errorMessage) 報告測試運行由於致命錯誤而未能完成。 |
void | testRunStarted (String runName, int testCount, int attemptNumber) 報告測試運行的開始。 |
void | testRunStarted (String runName, int testCount) 報告測試運行的開始。 |
void | testRunStarted (String runName, int testCount, int attemptNumber, long startTime) 報告測試運行的開始。 |
void | testRunStopped (long elapsedTime) 由於用戶請求,報告測試運行在完成之前停止。 |
void | testStarted ( TestDescription test, long startTime) 替代 |
void | testStarted ( TestDescription test) 報告單個測試用例的開始。 |
受保護的方法 | |
---|---|
getListeners () 獲取監聽器列表。 | |
void | setListeners ( listeners) setListeners ( listeners) 構建後設置監聽器。 |
void | setListeners ( ITestInvocationListener... listeners) 構建後設置監聽器。 |
公共構造函數
結果轉發器
public ResultForwarder (listeners)
創建一個ResultForwarder
。
參數 | |
---|---|
listeners | ITestInvocationListener 將結果轉發到 |
結果轉發器
public ResultForwarder (ITestInvocationListener... listeners)
ResultForwarder
的備用變量 arg 構造函數。
參數 | |
---|---|
listeners | ITestInvocationListener : 真正的ITestInvocationListener 將結果轉發到 |
受保護的構造函數
公共方法
獲取摘要
public TestSummary getSummary ()
允許 InvocationListener 返回摘要。
退貨 | |
---|---|
TestSummary | 總結運行的TestSummary ,或 null |
調用結束
public void invocationEnded (long elapsedTime)
報告調用已終止,無論是成功還是由於某些錯誤條件。
將由 TradeFederation 框架自動調用。參數 | |
---|---|
elapsedTime | long :調用的經過時間,以毫秒為單位 |
調用失敗
public void invocationFailed (FailureDescription failure)
由於某些錯誤情況,報告不完整的調用。
將由 TradeFederation 框架自動調用。
參數 | |
---|---|
failure | FailureDescription : 描述失敗原因的FailureDescription |
調用失敗
public void invocationFailed (Throwable cause)
由於某些錯誤情況,報告不完整的調用。
將由 TradeFederation 框架自動調用。參數 | |
---|---|
cause | Throwable : Throwable 失敗的原因 |
調用開始
public void invocationStarted (IInvocationContext context)
報告測試調用的開始。
將由 TradeFederation 框架自動調用。報告者需要覆蓋此方法以支持多設備報告。
參數 | |
---|---|
context | IInvocationContext :有關調用的信息 |
測試假設失敗
public void testAssumptionFailure (TestDescription test, String trace)
當原子測試標記它假定條件為假時調用
參數 | |
---|---|
test | TestDescription : 標識測試 |
trace | String :失敗的堆棧跟踪 |
測試假設失敗
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
當原子測試標記它假定條件為假時調用
參數 | |
---|---|
test | TestDescription : 標識測試 |
failure | FailureDescription : FailureDescription 描述失敗及其上下文。 |
測試結束
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) |
測試結束
public void testEnded (TestDescription test,testMetrics)
報告單個測試用例的執行結束。
如果未調用testFailed(TestDescription, FailureDescription)
,則此測試通過。還返回在測試用例執行期間可能已發出的任何鍵/值指標。
參數 | |
---|---|
test | TestDescription : 標識測試 |
testMetrics | ERROR(/Map) |
測試失敗
public void testFailed (TestDescription test, FailureDescription failure)
報告單個測試用例的失敗。
將在 testStarted 和 testEnded 之間調用。
參數 | |
---|---|
test | TestDescription : 標識測試 |
failure | FailureDescription : FailureDescription 描述失敗及其上下文。 |
測試失敗
public void testFailed (TestDescription test, String trace)
報告單個測試用例的失敗。
將在 testStarted 和 testEnded 之間調用。
參數 | |
---|---|
test | TestDescription : 標識測試 |
trace | String :失敗的堆棧跟踪 |
測試忽略
public void testIgnored (TestDescription test)
當測試不會運行時調用,通常是因為測試方法使用 org.junit.Ignore 註釋。
參數 | |
---|---|
test | TestDescription : 標識測試 |
測試日誌
public void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
提供來自測試調用的關聯日誌或調試數據。
必須在ERROR(/ITestInvocationListener#invocationFailed(Throwable))
或ERROR(/ITestInvocationListener#invocationEnded(long))
TradeFederation 框架將自動調用此方法,提供主機日誌和設備 logcat(如果適用)。參數 | |
---|---|
dataName | String : 數據的String 描述性名稱。例如“device_logcat”。注意 dataName 每次調用可能不是唯一的。即實現者必須能夠處理具有相同數據名稱的多個調用 |
dataType | LogDataType : 數據的LogDataType |
dataStream | InputStreamSource :數據的InputStreamSource 。實現者應調用 createInputStream 開始讀取數據,並確保在完成後關閉生成的 InputStream。調用者應確保數據源保持存在並可訪問,直到 testLog 方法完成。 |
測試模塊結束
public void testModuleEnded ()
報告模塊運行的結束。
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
報告正在運行的模塊的開始。此回調與testModuleEnded()
相關聯,並且在序列中是可選的。它僅在使用模塊的運行期間使用:基於套件的運行器。
參數 | |
---|---|
moduleContext | IInvocationContext :模塊的IInvocationContext 。 |
測試運行結束
public void testRunEnded (long elapsedTime,runMetrics)
報告測試運行結束。 FIXME:我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。
參數 | |
---|---|
elapsedTime | long :設備報告的經過時間,以毫秒為單位 |
runMetrics | Metric 的測試運行結束時報告的鍵值對。 |
測試運行失敗
public void testRunFailed (FailureDescription failure)
由於FailureDescription
描述的失敗,報告測試運行未能完成。
參數 | |
---|---|
failure | FailureDescription : FailureDescription 描述失敗及其上下文。 |
測試運行失敗
public void testRunFailed (String errorMessage)
報告測試運行由於致命錯誤而未能完成。
參數 | |
---|---|
errorMessage | String :描述運行失敗原因的String 。 |
測試運行開始
public void testRunStarted (String runName, int testCount, int attemptNumber)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int :測試運行中的測試總數 |
attemptNumber | int :訂單號,標識同一 runName 多次運行的不同嘗試。 attemptNumber 是 0-indexed 並且應該在每次新的運行發生時遞增。例如,一個測試是粒度重試 3 次,它應該在相同的 runName 下總共運行 4 次,並且嘗試編號是從 0 到 3。 |
測試運行開始
public void testRunStarted (String runName, int testCount)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int :測試運行中的測試總數 |
測試運行開始
public void testRunStarted (String runName, int testCount, int attemptNumber, long startTime)
報告測試運行的開始。
參數 | |
---|---|
runName | String : 測試運行名稱 |
testCount | int :測試運行中的測試總數 |
attemptNumber | int :訂單號,標識同一 runName 多次運行的不同嘗試。 attemptNumber 是 0-indexed 並且應該在每次新的運行發生時遞增。例如,一個測試是粒度重試 3 次,它應該在相同的 runName 下總共運行 4 次,並且嘗試編號是從 0 到 3。 |
startTime | long :運行開始的時間,通過System.currentTimeMillis() 測量 |
測試運行已停止
public void testRunStopped (long elapsedTime)
由於用戶請求,報告測試運行在完成之前停止。
TODO:目前未使用,考慮移除
參數 | |
---|---|
elapsedTime | long :設備報告的經過時間,以毫秒為單位 |
測試開始
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() 測量 |
測試開始
public void testStarted (TestDescription test)
報告單個測試用例的開始。舊界面,應盡可能使用testStarted(com.android.tradefed.result.TestDescription)
。
參數 | |
---|---|
test | TestDescription : 標識測試 |
受保護的方法
設置監聽器
protected void setListeners (listeners)
構建後設置監聽器。僅供子類使用。
參數 | |
---|---|
listeners | ITestInvocationListener 將結果轉發到 |
設置監聽器
protected void setListeners (ITestInvocationListener... listeners)
構建後設置監聽器。僅供子類使用。
參數 | |
---|---|
listeners | ITestInvocationListener : 真正的ITestInvocationListener 將結果轉發到 |