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)被調用。

實現此接口的類應注意,每當testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource)被調用。

此類還傳遞全局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)

保存測試日誌時調用。

公共方法

日誌關聯

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 ,應該與測試用例相關聯。

設置日誌保存器

public void setLogSaver (ILogSaver logSaver)

設置ILogSaver以允許實施者保存文件。

參數
logSaver ILogSaverILogSaver

測試日誌已保存

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

保存測試日誌時調用。

應該用來代替ITestInvocationListener#testLog(String, LogDataType, InputStreamSource)

參數
dataName String :數據的ERROR(/String)描述性名稱。例如“device_logcat”。注意 dataName 每次調用可能不是唯一的。即實現者必須能夠處理具有相同數據名的多個調用

dataType LogDataType :數據的LogDataType

dataStream InputStreamSource :數據的InputStreamSource 。實施者應調用 createInputStream 開始讀取數據,並確保在完成後關閉生成的 InputStream。

logFile LogFile :包含已保存文件的元數據的LogFile