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 的格式化程序不同,此类不会报告 测试的执行时间。

在内存中收集所有测试信息,然后在调用完成后转储到文件。

从 dalvik 运行程序 XmlReportPrinter 移植。

结果文件将存储在通过 [--output-file-path]/[build_id] 构建的路径中

摘要

公共构造函数

XmlResultReporter()

公共方法

void invocationEnded(long elapsedTime)

报告调用已终止,无论是成功终止还是因某些错误 情况而终止。

void setLogSaver(ILogSaver logSaver)

设置 ILogSaver,以允许实现者保存文件。

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 ILogSaverILogSaver

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