ILogSaverListener

public interface ILogSaverListener
implements ITestInvocationListener

com.android.tradefed.result.ILogSaverListener


允許 ITestInvocationListener 監聽記錄檔儲存時的事件。

這可讓多個 ITestInvocationListener 在產生報表時使用相同的已儲存記錄檔,並避免在呼叫 ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource) 時,讓每個監聽器個別儲存檔案。

實作此介面的類別應注意,每當呼叫 ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource) 時,就會呼叫 testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)

這個類別也會傳遞全域 ILogSaver 例項,讓 ITestInvocationListener 能夠在相同位置儲存其他檔案。

摘要

公用方法

default void logAssociation(String dataName, LogFile logFile)

在某些情況下,記錄必須與測試案例建立強連結,但無法直接在 testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) 回呼中執行此操作。

default void setLogSaver(ILogSaver logSaver)

設定 ILogSaver,允許實作者儲存檔案。

default void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

儲存測試記錄時呼叫。

公用方法

logAssociation

public void logAssociation (String dataName, 
                LogFile logFile)

在某些情況下,記錄必須與測試案例建立強烈關聯,但無法直接在 testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) 回呼上執行此操作。因此,這個回呼可明確提供強連結。

參數
dataName String:資料名稱

logFile LogFile:先前記錄的 LogFile,應與測試案例相關聯。

setLogSaver

public void setLogSaver (ILogSaver logSaver)

設定 ILogSaver,允許實作者儲存檔案。

參數
logSaver ILogSaverILogSaver

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