錯誤報告收集器

public class BugreportCollector
extends Object implements ITestInvocationListener

java.lang.Object
com.android.tradefed.result.BugreportCollector


一個傳遞ITestInvocationListener ,它在可設定事件發生時收集錯誤報告,然後在收集每個錯誤報告後在其子層級上呼叫ITestInvocationListener#testLog

行為:(FIXME:完成這個)

  • 在每個測試用例失敗後捕獲
  • 每個測試用例後捕獲
  • 在每個失敗的測試案例後捕獲
  • 捕獲

概括

嵌套類

class BugreportCollector.Predicate

描述何時捕獲錯誤報告的完整謂詞。

interface BugreportCollector.SubPredicate

領域

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

在每個失敗的測試案例後觸發的預定義謂詞

public static final BugreportCollector.Predicate AT_START

第一次呼叫開始時觸發的預定義謂詞

公共構造函數

BugreportCollector ( ITestInvocationListener listener, ITestDevice testDevice)

公共方法

void addPredicate ( BugreportCollector.Predicate p)
void blockUntilIdle ()

阻塞直到收集器不再收集任何錯誤報告。

TestSummary getSummary ()

允許 IncationListener 傳回摘要。

void invocationEnded (long elapsedTime)

報告呼叫已終止,無論是成功還是由於某些錯誤情況。

void invocationFailed (Throwable cause)

由於某些錯誤情況而報告不完整的呼叫。

void invocationStarted ( IInvocationContext context)

報告測試調用的開始。

void setAsynchronous (boolean asynchronous)

設定錯誤報告收集是否應在不同執行緒中收集錯誤報告 ( asynchronous = true ),或阻止呼叫者直到捕獲錯誤報告 ( asynchronous = false )。

void setDescriptiveName (String name)

設定記錄錯誤報告時使用的描述性名稱。

void setDeviceWaitTime (int waitTime)

設定在嘗試捕獲錯誤報告之前等待設備上線的時間(以秒為單位)。

void testAssumptionFailure ( TestDescription test, String trace)

當原子測試標記其假定條件為 false 時調用

void testEnded ( TestDescription test, testMetrics) testEnded ( TestDescription test, testMetrics)

報告單一測試案例的執行結束。

void testFailed ( TestDescription test, String trace)

報告單一測試用例的失敗。

void testIgnored ( TestDescription test)

當測試不會運行時調用,通常是因為測試方法用 org.junit.Ignore 註解。

void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)

提供來自測試調用的關聯日誌或調試資料。

void testRunEnded (long elapsedTime, runMetrics) testRunEnded (long elapsedTime, runMetrics)

報告測試運行結束。

void testRunFailed (String errorMessage)

報告測試運行因致命錯誤而未能完成。

void testRunStarted (String runName, int testCount)

報告測試運行的開始。

void testRunStopped (long elapsedTime)

由於用戶請求,報告測試運行在完成之前停止。

void testStarted ( TestDescription test)

報告單一測試用例的開始。

領域

AFTER_FAILED_TESTCASES

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

在每個失敗的測試案例後觸發的預定義謂詞

AT_START

public static final BugreportCollector.Predicate AT_START

第一次呼叫開始時觸發的預定義謂詞

公共構造函數

錯誤報告收集器

public BugreportCollector (ITestInvocationListener listener, 
                ITestDevice testDevice)

參數
listener ITestInvocationListener

testDevice ITestDevice

公共方法

加上謂詞

public void addPredicate (BugreportCollector.Predicate p)

參數
p BugreportCollector.Predicate

阻塞直到空閒

public void blockUntilIdle ()

阻塞直到收集器不再收集任何錯誤報告。如果收集器沒有主動收集錯誤報告,請立即返回

取得摘要

public TestSummary getSummary ()

允許 IncationListener 傳回摘要。

退貨
TestSummary總結運行的TestSummary ,或 null

呼叫結束

public void invocationEnded (long elapsedTime)

報告呼叫已終止,無論是成功還是由於某些錯誤情況。

將由 TradeFederation 框架自動呼叫。

參數
elapsedTime long :呼叫所花費的時間(以毫秒為單位)

呼叫失敗

public void invocationFailed (Throwable cause)

由於某些錯誤情況而報告不完整的呼叫。

將由 TradeFederation 框架自動呼叫。

參數
cause Throwable :失敗的Throwable原因

調用開始

public void invocationStarted (IInvocationContext context)

報告測試調用的開始。

將由 TradeFederation 框架自動呼叫。記者需要重寫此方法以支援多設備報告。

參數
context IInvocationContext :有關呼叫的信息

設定異步

public void setAsynchronous (boolean asynchronous)

設定錯誤報告收集是否應在不同執行緒中收集錯誤報告 ( asynchronous = true ),或阻止呼叫者直到捕獲錯誤報告 ( asynchronous = false )。

參數
asynchronous boolean

設定描述性名稱

public void setDescriptiveName (String name)

設定記錄錯誤報告時使用的描述性名稱。如果為nullBugreportCollector將回退到序列化導致收集錯誤報告的事件名稱的預設行為。

參數
name String

設定設備等待時間

public void setDeviceWaitTime (int waitTime)

設定在嘗試捕獲錯誤報告之前等待設備上線的時間(以秒為單位)。如果是否定的,則不會執行任何檢查。在此檢查期間遇到的任何DeviceNotAvailableException將被記錄並忽略。

參數
waitTime int

測試假設失敗

public void testAssumptionFailure (TestDescription test, 
                String trace)

當原子測試標記其假定條件為 false 時調用

參數
test TestDescription :標識測試

trace String : 失敗的堆疊追蹤

測試結束

public void testEnded (TestDescription test, 
                 testMetrics)

報告單一測試案例的執行結束。

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

參數
test TestDescription :標識測試

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

測試失敗

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 可能不是唯一的。即實現者必須能夠處理具有相同 dataName 的多個呼叫

dataType LogDataType :資料的LogDataType

dataStream InputStreamSource :資料的InputStreamSource 。實作者應該呼叫 createInputStream 來開始讀取數據,並確保完成後關閉產生的 InputStream。呼叫者應確保資料來源保持存在且可訪問,直到 testLog 方法完成。

測試運行結束

public void testRunEnded (long elapsedTime, 
                 runMetrics)

報告測試運行結束。 FIXME:我們不能有兩個不同類型的 Map<> 接口,所以我們必須在這裡使用 HashMap。

參數
elapsedTime long :設備報告的經過時間,以毫秒為單位

runMetrics :使用Metric測試運行結束時報告的鍵值對。

測試運行失敗

public void testRunFailed (String errorMessage)

報告測試運行因致命錯誤而未能完成。

參數
errorMessage String :描述運行失敗原因的String

測試運行開始

public void testRunStarted (String runName, 
                int testCount)

報告測試運行的開始。

參數
runName String : 測試運行名稱

testCount int : 測試運行中的測試總數

測試運行停止

public void testRunStopped (long elapsedTime)

由於用戶請求,報告測試運行在完成之前停止。

TODO:目前未使用,考慮刪除

參數
elapsedTime long :設備報告的經過時間,以毫秒為單位

測試開始

public void testStarted (TestDescription test)

報告單一測試用例的開始。較舊的接口,應盡可能使用testStarted(com.android.tradefed.result.TestDescription)

參數
test TestDescription :標識測試