XmlResultReporter
public
class
XmlResultReporter
extends CollectingTestListener
implements
ILogSaverListener
| java.lang.Object | ||
| ↳ | com.android.tradefed.result.CollectingTestListener | |
| ↳ | com.android.tradefed.result.XmlResultReporter | |
以符合 Ant 的 XMLJUnitResultFormatter 格式,將 JUnit 結果寫入 XML 檔案。
與 Ant 的格式化工具不同,這個類別不會回報測試的執行時間。
在記憶體中收集所有測試資訊,然後在叫用完成時傾印至檔案。
Ported from dalvik runner XmlReportPrinter.
結果檔案會儲存在透過 [--output-file-path]/[build_id] 建構的路徑中
摘要
公用建構函式 | |
|---|---|
XmlResultReporter()
|
|
公用方法 | |
|---|---|
void
|
invocationEnded(long elapsedTime)
回報是否因某種錯誤狀況而終止呼叫 (無論是否成功)。 |
void
|
setLogSaver(ILogSaver logSaver)
設定 |
void
|
testFailed(TestDescription test, String trace)
回報個別測試案例的失敗情形。 |
void
|
testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
提供測試呼叫的相關記錄或偵錯資料。 |
void
|
testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)
測試記錄儲存完畢時呼叫。 |
公用建構函式
XmlResultReporter
public XmlResultReporter ()
公用方法
invocationEnded
public void invocationEnded (long elapsedTime)
回報是否因某種錯誤情況而終止呼叫 (無論是否成功)。
TradeFederation 架構會自動呼叫。
| 參數 | |
|---|---|
elapsedTime |
long:以毫秒為單位的呼叫經過時間 |
setLogSaver
public void setLogSaver (ILogSaver logSaver)
設定 ILogSaver,允許實作者儲存檔案。
| 參數 | |
|---|---|
logSaver |
ILogSaver:ILogSaver |
testFailed
public void testFailed (TestDescription test, String trace)
回報個別測試案例的失敗情形。
會在 testStarted 和 testEnded 之間呼叫。
| 參數 | |
|---|---|
test |
TestDescription:識別測試 |
trace |
String:失敗的堆疊追蹤 |
testLog
public void testLog (String dataName,
LogDataType dataType,
InputStreamSource dataStream)提供測試呼叫的相關記錄或偵錯資料。
必須在 ERROR(ITestInvocationListener.invocationFailed(Throwable)/ITestInvocationListener#invocationFailed(java.lang.Throwable) 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 方法完成為止。 |
testLogSaved
public void testLogSaved (String dataName,
LogDataType dataType,
InputStreamSource dataStream,
LogFile logFile)測試記錄儲存完畢時呼叫。
應取代 ITestInvocationListener.testLog(String,LogDataType,InputStreamSource) 使用。
| 參數 | |
|---|---|
dataName |
String:資料的String說明名稱,例如「device_logcat」。注意:dataName 在每次呼叫時可能不具唯一性,也就是說,實作者必須能夠處理具有相同 dataName 的多項呼叫。 |
dataType |
LogDataType:資料的 LogDataType |
dataStream |
InputStreamSource:資料的 InputStreamSource。實作者應呼叫 createInputStream 開始讀取資料,並確保在完成時關閉產生的 InputStream。 |
logFile |
LogFile:包含已儲存檔案中繼資料的 LogFile。 |